On 27/03/17 19:26, ToddAndMargo wrote:
> and `none("789")` is the opposite of `contains`?

Nah, the fact that anything in the junction means "contains" is just
because you're feeding the junction through the contains method.

Junction evaluation happens with something we call "autothreading" (even
though no actual multithreading happens). When a function or method gets
called with a junction, the call will be split up to each of the parts
of the junction, and the result values are used to construct a new junction.

Here's an example:

uc("Hello" | "Goodbye" | "what") → uc("Hello") | uc("Goodbye") | uc("what")

junctions are most useful when you have something on the outside that
handles Bool values, because then the difference between "all", "any",
"one", and "none" actually do something:

("hello" | "goodbye" | "what").chars == 4 → ("hello".chars |
"goodbye".chars | "what".chars) == 4 → (5 | 7 | 4) == 4 → (False | False
| True) → True (because any of the three bools was True)

So with your all + none here's how it goes:

$x.contains($y & "abc" & none("789)) → $x.contains($y) &
$x.contains("abc") & none($x.contains("789"))

now here's the interesting part. $x.contains("789") evaluates to False,
and none(False) is True (none of the entries are True, giving True as
the result).

Now you have True & True & none(False) → True & True & True → True

HTH
  - Timo

Reply via email to