aboutsummaryrefslogtreecommitdiff
path: root/gen/src
diff options
context:
space:
mode:
Diffstat (limited to 'gen/src')
-rw-r--r--gen/src/gleam@string.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/gen/src/gleam@string.erl b/gen/src/gleam@string.erl
index a09e7e4..d383316 100644
--- a/gen/src/gleam@string.erl
+++ b/gen/src/gleam@string.erl
@@ -1,7 +1,7 @@
-module(gleam@string).
-compile(no_auto_import).
--export([is_empty/1, length/1, reverse/1, replace/3, lowercase/1, uppercase/1, compare/2, split/2, append/2, concat/1, join/2]).
+-export([is_empty/1, length/1, reverse/1, replace/3, lowercase/1, uppercase/1, compare/2, contains/2, split/2, append/2, concat/1, repeat/2, join/2]).
is_empty(Str) ->
Str =:= <<"">>.
@@ -26,6 +26,12 @@ uppercase(A) ->
compare(A, B) ->
gleam_stdlib:compare_strings(A, B).
+erl_contains(A, B) ->
+ gleam_stdlib:string_contains(A, B).
+
+contains(Haystack, Needle) ->
+ erl_contains(Haystack, Needle).
+
split(X, Substring) ->
gleam@list:map(
gleam@iodata:split(gleam@iodata:new(X), Substring),
@@ -40,6 +46,18 @@ append(First, Second) ->
concat(Strings) ->
gleam@iodata:to_string(gleam@iodata:from_strings(Strings)).
+repeat_help(Chunk, Result, Repeats) ->
+ case Repeats =< 0 of
+ true ->
+ concat(Result);
+
+ false ->
+ repeat_help(Chunk, [Chunk | Result], Repeats - 1)
+ end.
+
+repeat(String, Times) ->
+ repeat_help(String, [<<"">>], Times).
+
join(Strings, Separator) ->
gleam@iodata:to_string(
gleam@iodata:from_strings(gleam@list:intersperse(Strings, Separator))