You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should add a new example which shows people how to make conversions to/from Upper and Lower case using only the builtins.
We should briefly explain the trade-offs, and how there will be packages available to provide additional functionality. Could even point people towards https://github.com/Hasnep/roc-ascii
Below is a quick and dirty implementation... we should modify this to handle the Result correctly, and polish it a little with some explanation and examples.
module [to_upper, to_lower]
to_upper : Str -> Strto_upper = \str ->
str
|>Str.toUtf8|>List.map to_upper_help
|>Str.fromUtf8|> unwrap
to_lower : Str -> Strto_lower = \str ->
str
|>Str.toUtf8|>List.map to_lower_help
|>Str.fromUtf8|> unwrap
expect to_upper "hello"=="HELLO"expect to_upper "Hello"=="HELLO"expect to_lower "HELLO"=="hello"expect to_lower "Hello"=="hello"to_upper_help = \c -> if c >='a'&& c <='z'then c - delta else c
to_lower_help = \c -> if c >='A'&& c <='Z'then c + delta else c
delta = 'a'-'A'unwrap : Result a _ -> a
unwrap = \result ->
when result isOk a -> a
Err_ -> crash "quick and dirty error handling"
The text was updated successfully, but these errors were encountered:
See zulip discussion for context
We should add a new example which shows people how to make conversions to/from Upper and Lower case using only the builtins.
We should briefly explain the trade-offs, and how there will be packages available to provide additional functionality. Could even point people towards https://github.com/Hasnep/roc-ascii
Below is a quick and dirty implementation... we should modify this to handle the Result correctly, and polish it a little with some explanation and examples.
The text was updated successfully, but these errors were encountered: