Created
July 19, 2022 20:17
-
-
Save gfldex/42694c8f7b8b7cae697566cf335f946e 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
# Did you know, you can use the method `.none` (and friends) of `Any` in a method call chain? | |
my \fib = 1, 1, * + * … ∞; | |
say so fib[^10].none.is-prime; | |
say so fib[^10].any.is-prime; | |
say so fib[5..9].one.is-prime; | |
# A `Junction` is a parallel value that whats to collaps into a single `Bool`. Any method call to a definite `Junction` will be forwarded to its members, coerced to `Bool` and collapsed with the `Junction`-type. The above `any`-form is equivalent to: | |
say fib[^10].map(*.is-prime).reduce(&[||]) | |
# [`Junctions` https://docs.raku.org/type/Junction] come in many forms and can make you code quite neat. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment