diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-10-09 22:11:22 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-10-09 22:11:22 -0400 |
| commit | 0ebe9ea698213413f2652ab587e3953e0206b356 (patch) | |
| tree | fed1e5f69f87ffa4f2c3a4423fc791f37b7a6481 /doc | |
| parent | afc086a54b9f37acd4d90ff6cc607ab3008c78f9 (diff) | |
Point out use of immediate block with predicates
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/block.md | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/block.md b/doc/block.md index 27cb47ae..85ea1a03 100644 --- a/doc/block.md +++ b/doc/block.md @@ -202,7 +202,7 @@ The body where the predicate appears doesn't need to start with a header, and th { r←⌽𝕩 ⋄ 't'=⊑r ? r ; 𝕩 }¨ "test"‿"this" -So `r` is the reversed argument, and if its first character (the last one in `𝕩`) is `'t'` then it returns `r`, and otherwise we abandon that line of reasoning and return `𝕩`. This sounds a lot like an if statement. And `{ a<b ? a ; b }`, which computes `a⌊b` the hard way, shows how the syntax can be similar to a ternary operator. But `?;` is more flexible than that. It can support any number of options, with multiple tests for each one—the structure below is "if \_ and \_ then \_; else if \_ then \_; else \_". +So `r` is the reversed argument, and if its first character (the last one in `𝕩`) is `'t'` then it returns `r`, and otherwise we abandon that line of reasoning and return `𝕩`. This sounds a lot like an if statement. And `{ a<b ? a ; b }`, which computes `a⌊b` the hard way, shows how the syntax can be similar to a ternary operator. This is an immediate block with multiple bodies, something that makes sense with predicates but not headers. But `?;` offers more possibilities. It can support any number of options, with multiple tests for each one—the structure below is "if \_ and \_ then \_; else if \_ then \_; else \_". Thing ← { 𝕩≥3? 𝕩≤8? 2|𝕩 ; 𝕩=0? @ ; ∞ } |
