-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat(stdlib): Add More String Iteration Functions #1864
base: main
Are you sure you want to change the base?
Conversation
stdlib/string.gr
Outdated
* @since v0.6.0 | ||
*/ | ||
@unsafe | ||
provide let forEachChar = (fn: Char -> Void, str: String) => { |
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.
You could probably share some code between this function and forEachCodePoint
; same with forEachChari
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.
I made the idx
change, but I dont think it is optimial to share code here, the type signatures of fn
are different so its not as simple as just having a bool that says to use char or code point. meaning you would need to use a wrapper function into the helper that tags the char, which it invokes an extra function call. On another note if we do want to go this route we might as well justhave a forEachCodePointIHelper
which returns an unsafe code point. and then each function just becomes forEachCodePointIHelper((c, _) => fn(tagChar(c)), str)
.
bf351f2
to
f9d7abb
Compare
ab94524
to
36318b0
Compare
This pr adds
forEachChar
,forEachCharI
,map
andmapi
to the String library.