F <x< G
The execution of F <x< G
starts by executing F and G in parallel. Whenever
F publishes a value, that value is published by the entire execution. When G publishes its first value, that
value is bound to x in F, and then the execution of G is immediately killed.
A killed expression cannot call any sites or publish any values. During the execution of F,
any part of the execution that depends on x
will be blocked until x is bound (to
the first value published by G). If G never publishes a value, those parts remain blocked forever.
F <P< G
The pruning combinator may include a full pattern P instead of just a variable name. Any value published
by G is matched against the pattern P. If this match is successful, then G is killed and all of the bindings
of pattern P are made in F. Otherwise, the published value is simply ignored and G continues to execute.
F << G
This is equivalent to using a wildcard pattern, F <_< G. G continues to execute
until it publishes a value. Any value published by G will match the pattern. After the successful match,
G is killed, but no bindings are made in F.
No part of execution of F is suspended by the pruning combinator since there is no variable to be bound.
|
Combinator Precedence Level: sequential > parallel > pruning > otherwise [Full Table]
The type of F <P< G
is the type of F in the context ΓG,
where ΓG is the result of matching the pattern P against the type of G.
{- Simulate a coin toss by publishing either "heads" or "tails" arbitrarily -} x <x< ("heads" | "tails") {- OUTPUT: "heads" -} {- OUTPUT: "tails" -}
include "search.inc" {- Query Google and Yahoo for a search result Print out the result that arrives first; ignore the other result -} Println(result) <result< ( Google("cupcake") | Yahoo("cupcake") )
{- Publish either 9 or 25, but not 16. -} x*x <(x,true)< ( (3,true) | (4,false) | (5,true) ) {- OUTPUT: 9 -} {- OUTPUT: 25 -}
{- Print all publications of the metronome function for 90 msec (after the execution of metronome starts). Then kill metronome. Note that metronome(20) publishes a signal every 20 msec. -} stop << (metronome(20) >x> Println(x) >> stop | Rwait(90) ) {- OUTPUT: signal signal signal signal signal -}
Related Reference Topics
Related Tutorial Sections