aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
authorgreggreg <greg@greggreg.org>2020-04-16 08:50:24 -0600
committerLouis Pilfold <louis@lpil.uk>2020-04-16 16:23:19 +0100
commitbfdde0ee0b60482f5d41e7e6cbae2b11f9daf08f (patch)
tree15df4af63010fb0010b821dcf6f4b5000b4f7479 /src/gleam_stdlib.erl
parent95ad77fdd2a5f2282eee5248921973863f998427 (diff)
downloadgleam_stdlib-bfdde0ee0b60482f5d41e7e6cbae2b11f9daf08f.tar.gz
gleam_stdlib-bfdde0ee0b60482f5d41e7e6cbae2b11f9daf08f.zip
Implementing String.contains and String.repeat
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index 1f1f652..9e6a864 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -6,7 +6,8 @@
atom_create_from_string/1, atom_to_string/1, map_get/2,
iodata_append/2, iodata_prepend/2, identity/1, decode_int/1,
decode_string/1, decode_bool/1, decode_float/1, decode_thunk/1, decode_atom/1,
- decode_list/1, decode_field/2, decode_element/2, parse_int/1, parse_float/1, compare_strings/2]).
+ decode_list/1, decode_field/2, decode_element/2, parse_int/1, parse_float/1, compare_strings/2,
+ string_contains/2]).
should_equal(Actual, Expected) -> ?assertEqual(Expected, Actual).
should_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual).
@@ -107,3 +108,11 @@ compare_strings(Lhs, Rhs) ->
true ->
gt
end.
+
+string_contains(Haystack, Needle) ->
+ case string:find(Haystack, Needle) of
+ nomatch ->
+ false;
+ _ ->
+ true
+ end.