From bfdde0ee0b60482f5d41e7e6cbae2b11f9daf08f Mon Sep 17 00:00:00 2001 From: greggreg Date: Thu, 16 Apr 2020 08:50:24 -0600 Subject: Implementing String.contains and String.repeat --- src/gleam_stdlib.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/gleam_stdlib.erl') 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. -- cgit v1.2.3