From 5a1f3494eb9517a7b7a332cb74dd10a6a7d32d31 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Wed, 29 May 2019 21:02:55 +0100 Subject: Enable namespaced modules --- src/std/string.gleam | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/std/string.gleam (limited to 'src/std/string.gleam') diff --git a/src/std/string.gleam b/src/std/string.gleam new file mode 100644 index 0000000..9eacb37 --- /dev/null +++ b/src/std/string.gleam @@ -0,0 +1,36 @@ +import std/iodata +import std/list + +pub external fn length(String) -> Int = "string" "length" + +pub enum ParseError = + | ParseError + +pub external fn lowercase(String) -> String = "string" "lowercase" + +pub external fn uppercase(String) -> String = "string" "uppercase" + +pub fn reverse(string) { + string + |> iodata:new + |> iodata:reverse + |> iodata:to_string +} + +pub fn split(string, on) { + string + |> iodata:new + |> iodata:split(_, on) + |> list:map(_, iodata:to_string) +} + +pub fn replace(string, pattern, with) { + string + |> iodata:new + |> iodata:replace(_, pattern, with) + |> iodata:to_string +} + +pub fn append(s1, s2) { + iodata:new(s1) |> iodata:append(_, s2) |> iodata:to_string(_) +} -- cgit v1.2.3