(module vec_string (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (type VecString (vec string)) (fn empty () -> VecString (std.vec.string.empty)) (fn append ((values VecString) (value string)) -> VecString (std.vec.string.append values value)) (fn len ((values VecString)) -> i32 (std.vec.string.len values)) (fn at ((values VecString) (position i32)) -> string (std.vec.string.index values position)) (fn singleton ((value string)) -> VecString (append (empty) value)) (fn append2 ((values VecString) (first string) (second string)) -> VecString (append (append values first) second)) (fn append3 ((values VecString) (first string) (second string) (third string)) -> VecString (append (append2 values first second) third)) (fn pair ((first string) (second string)) -> VecString (append2 (empty) first second)) (fn triple ((first string) (second string) (third string)) -> VecString (append3 (empty) first second third)) (fn is_empty ((values VecString)) -> bool (= (len values) 0)) (fn index_or ((values VecString) (position i32) (fallback string)) -> string (if (< position 0) fallback (if (< position (len values)) (at values position) fallback))) (fn first_or ((values VecString) (fallback string)) -> string (index_or values 0 fallback)) (fn last_or ((values VecString) (fallback string)) -> string (if (is_empty values) fallback (at values (- (len values) 1)))) (fn index_option ((values VecString) (position i32)) -> (option string) (if (< position 0) (none string) (if (< position (len values)) (some string (at values position)) (none string)))) (fn first_option ((values VecString)) -> (option string) (index_option values 0)) (fn last_option ((values VecString)) -> (option string) (if (is_empty values) (none string) (some string (at values (- (len values) 1))))) (fn index_of_option_loop ((values VecString) (target string) (position i32) (values_len i32)) -> (option i32) (if (< position values_len) (if (= (at values position) target) (some i32 position) (index_of_option_loop values target (+ position 1) values_len)) (none i32))) (fn index_of_option ((values VecString) (target string)) -> (option i32) (index_of_option_loop values target 0 (len values))) (fn last_index_of_option_loop ((values VecString) (target string) (position i32) (values_len i32) (found (option i32))) -> (option i32) (if (< position values_len) (if (= (at values position) target) (last_index_of_option_loop values target (+ position 1) values_len (some i32 position)) (last_index_of_option_loop values target (+ position 1) values_len found)) found)) (fn last_index_of_option ((values VecString) (target string)) -> (option i32) (last_index_of_option_loop values target 0 (len values) (none i32))) (fn contains_loop ((values VecString) (target string) (position i32) (values_len i32)) -> bool (if (< position values_len) (if (= (at values position) target) true (contains_loop values target (+ position 1) values_len)) false)) (fn contains ((values VecString) (target string)) -> bool (contains_loop values target 0 (len values))) (fn count_of_loop ((values VecString) (target string) (position i32) (values_len i32) (hits i32)) -> i32 (if (< position values_len) (count_of_loop values target (+ position 1) values_len (+ hits (if (= (at values position) target) 1 0))) hits)) (fn count_of ((values VecString) (target string)) -> i32 (count_of_loop values target 0 (len values) 0)) (fn concat_loop ((built VecString) (right VecString) (position i32) (right_len i32)) -> VecString (if (< position right_len) (concat_loop (append built (at right position)) right (+ position 1) right_len) built)) (fn concat ((left VecString) (right VecString)) -> VecString (let right_len i32 (len right)) (concat_loop left right 0 right_len)) (fn take_loop ((values VecString) (position i32) (limit i32) (built VecString)) -> VecString (if (< position limit) (take_loop values (+ position 1) limit (append built (at values position))) built)) (fn take ((values VecString) (count i32)) -> VecString (let values_len i32 (len values)) (if (< count 0) (empty) (if (< count values_len) (take_loop values 0 count (empty)) values))) (fn starts_with ((values VecString) (prefix VecString)) -> bool (let prefix_len i32 (len prefix)) (if (< (len values) prefix_len) false (= (take values prefix_len) prefix))) (fn without_prefix ((values VecString) (prefix VecString)) -> VecString (if (starts_with values prefix) (drop values (len prefix)) values)) (fn ends_with ((values VecString) (suffix VecString)) -> bool (let values_len i32 (len values)) (let suffix_len i32 (len suffix)) (if (< values_len suffix_len) false (= (drop values (- values_len suffix_len)) suffix))) (fn without_suffix ((values VecString) (suffix VecString)) -> VecString (if (ends_with values suffix) (take values (- (len values) (len suffix))) values)) (fn drop_loop ((values VecString) (position i32) (values_len i32) (built VecString)) -> VecString (if (< position values_len) (drop_loop values (+ position 1) values_len (append built (at values position))) built)) (fn drop ((values VecString) (count i32)) -> VecString (let values_len i32 (len values)) (if (< count 0) values (if (< count values_len) (drop_loop values count values_len (empty)) (empty)))) (fn reverse_loop ((values VecString) (position i32) (built VecString)) -> VecString (if (< position 0) built (reverse_loop values (- position 1) (append built (at values position))))) (fn reverse ((values VecString)) -> VecString (reverse_loop values (- (len values) 1) (empty))) (fn subvec ((values VecString) (start i32) (end_exclusive i32)) -> VecString (if (< start 0) (empty) (if (< start end_exclusive) (take (drop values start) (- end_exclusive start)) (empty)))) (fn insert_at ((values VecString) (position i32) (value string)) -> VecString (let values_len i32 (len values)) (if (< position 0) values (if (< position values_len) (concat (append (take values position) value) (drop values position)) (if (= position values_len) (append values value) values)))) (fn insert_range ((values VecString) (position i32) (inserted VecString)) -> VecString (let values_len i32 (len values)) (if (< position 0) values (if (< position values_len) (concat (concat (take values position) inserted) (drop values position)) (if (= position values_len) (concat values inserted) values)))) (fn replace_at ((values VecString) (position i32) (replacement string)) -> VecString (if (< position 0) values (if (< position (len values)) (concat (append (take values position) replacement) (drop values (+ position 1))) values))) (fn replace_range ((values VecString) (start i32) (end_exclusive i32) (replacement VecString)) -> VecString (let values_len i32 (len values)) (if (< start 0) values (if (< start values_len) (if (< start end_exclusive) (concat (concat (take values start) replacement) (drop values end_exclusive)) values) values))) (fn remove_at ((values VecString) (position i32)) -> VecString (if (< position 0) values (if (< position (len values)) (concat (take values position) (drop values (+ position 1))) values))) (fn remove_range ((values VecString) (start i32) (end_exclusive i32)) -> VecString (let values_len i32 (len values)) (if (< start 0) values (if (< start values_len) (if (< start end_exclusive) (concat (take values start) (drop values end_exclusive)) values) values)))