Created
December 2, 2023 03:12
-
-
Save darius/342109fa899ca0aa1ea3251ec919c59d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; "The ultimate conditional syntax" by Lionell Parreaux, examples | |
;; (untested translations to Cant) | |
;; Example 1 | |
(hm (may some-value | |
(be {none} 0)) | |
(let _ (console .log "It's not none!")) | |
(may some-value | |
(be {some {~ {some name} {left str}}} | |
(do [(name name.capitalize)] | |
(may value | |
(be "" (chain name " has no value")) | |
(be str (chain name " has value " str))))) | |
(be {some {none} (or {right} {left})} | |
"anonymous"))) | |
;; Figure 1 | |
(may name | |
(be (-- (? (~ .prefix? "_")) | |
(-> ~.tail-option {some name-postfix}) | |
(when (every ~.digit? name-postfix)) | |
(-> ||name-postfix.to-int-option {some index}) | |
(when (and (< 0 index) (<= index arity)))) | |
{right {~ index name}}) | |
(else | |
{left name})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment