Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created July 19, 2022 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfldex/42694c8f7b8b7cae697566cf335f946e to your computer and use it in GitHub Desktop.
Save gfldex/42694c8f7b8b7cae697566cf335f946e to your computer and use it in GitHub Desktop.
# 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