Skip to content

Commit

Permalink
Add Elm core library function String.map and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Jan 17, 2025
1 parent 6653ce4 commit 92e2e2e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions implement/pine/Elm/elm-compiler/elm-kernel-modules/String.elm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ foldr func acc (String chars) =
foldlChars func acc (Pine_kernel.reverse chars)


map : (Char -> Char) -> String -> String
map func (String chars) =
String (List.map func chars)


repeat : Int -> String -> String
repeat n (String chars) =
String (Pine_kernel.concat (List.repeat n chars))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,11 @@ foldr func acc (String chars) =
foldlChars func acc (Pine_kernel.reverse chars)
map : (Char -> Char) -> String -> String
map func (String chars) =
String (List.map func chars)
repeat : Int -> String -> String
repeat n (String chars) =
String (Pine_kernel.concat (List.repeat n chars))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"a.b.c"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
String.map (\c -> if c == '/' then '.' else c) "a/b/c"

0 comments on commit 92e2e2e

Please sign in to comment.