-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add remaining String SDK Functions #588
Conversation
examples/morphir-elm-projects/evaluator-tests/src/Morphir/Examples/App/StringTests.elm
Outdated
Show resolved
Hide resolved
examples/morphir-elm-projects/evaluator-tests/src/Morphir/Examples/App/StringTests.elm
Show resolved
Hide resolved
after you merge, can you also update this page? https://morphir.finos.org/docs/scala/morphir-scala-support/ |
{-| | ||
|
||
Test: String/foldl | ||
input = UPPERCASE, expected = True | ||
input = lowercase, expected = False | ||
input = camelCase, expected = False | ||
|
||
-} | ||
stringFoldlTest : String -> Bool | ||
stringFoldlTest input = | ||
String.foldl (\char acc -> acc && (char >= 'A' && char <= 'Z')) True input | ||
|
||
|
||
{-| | ||
|
||
Test: String/foldr | ||
input = "Hello, World", expected = 2 | ||
input = "HELLO, WORLD", expected = 10 | ||
|
||
-} | ||
stringFoldrTest : String -> Int | ||
stringFoldrTest input = | ||
String.foldr | ||
(\char count -> | ||
if char >= 'A' && char <= 'Z' then | ||
count + 1 | ||
|
||
else | ||
count | ||
) | ||
0 | ||
input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just use the examples from https://package.elm-lang.org/packages/elm/core/latest/String as the test cases, so that the difference between foldl
and foldr
is clear?
foldl cons "" "time" == "emit"
foldr cons "" "time" == "time"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
sure but don't i need a release version for that? |
it's currently only versioned on morphir-elm, and you don't need to update that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Opened a PR to update docs: https://github.com/finos/morphir/pull/259/files |
This PR adds support for the below String functions