Skip to content
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

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

sahilravinder
Copy link
Contributor

This PR adds support for the below String functions

  • sdk.StringSDK.fromChar
  • sdk.StringSDK.cons
  • sdk.StringSDK.uncons
  • sdk.StringSDK.toList
  • sdk.StringSDK.fromList
  • sdk.StringSDK.pad
  • sdk.StringSDK.map
  • sdk.StringSDK.filter
  • sdk.StringSDK.foldl
  • sdk.StringSDK.foldr
  • sdk.StringSDK.any
  • sdk.StringSDK.all

@michelchan
Copy link
Contributor

after you merge, can you also update this page? https://morphir.finos.org/docs/scala/morphir-scala-support/

Comment on lines 427 to 458
{-|

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
Copy link
Contributor

@bensanchin bensanchin Apr 17, 2024

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"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sahilravinder
Copy link
Contributor Author

after you merge, can you also update this page? https://morphir.finos.org/docs/scala/morphir-scala-support/

sure but don't i need a release version for that?

@michelchan
Copy link
Contributor

after you merge, can you also update this page? https://morphir.finos.org/docs/scala/morphir-scala-support/

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

Copy link
Contributor

@michelchan michelchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@bensanchin bensanchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sahilravinder sahilravinder merged commit f7f3c5b into finos:main Apr 18, 2024
14 checks passed
@sahilravinder sahilravinder deleted the string-sdk-functions branch April 18, 2024 16:33
@sahilravinder
Copy link
Contributor Author

after you merge, can you also update this page? https://morphir.finos.org/docs/scala/morphir-scala-support/

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

Opened a PR to update docs: https://github.com/finos/morphir/pull/259/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants