|
Combinator Precedence Level: sequential > parallel > pruning > otherwise [Full Table]
F ; G ; H | = | ( F ; G ) ; H | (Left Associative) |
F ; G ; H | = | F ; ( G ; H ) | (Right Associative) |
The type of F
;
G
is the join of the types of F
and G
.
include "search.inc" {- Attempt to retrieve search results from Google. If Google does not respond, then use Yahoo. -} Google("cupcake") ; Yahoo("cupcake")
{- A call to sum(n, xs), where n is an integer and xs is a list of integers, find the first sublist of xs lexicographically whose elements add up to n. The call publishes nothing if there is no solution -} def sum(0,[]) = [] def sum(n,[]) = stop def sum(n, x:xs) = x:sum(n-x, xs) ; sum(n, xs) sum(-5,[-2,5,1,4,8,-7]) {- OUTPUT: [-2, 4, -7] -}
{- Transfer all items from a channel to a list. Assume that the process has exclusive access to the channel, so that no other process is adding or removing items. -} def xfer(ch) = ch.getD() >x> x:xfer(ch) ; [] val ch = Channel() ch.put(1) >> ch.put(2) >> ch.put(3) >> ch.put(4) >> xfer(ch) {- OUTPUT: [1, 2, 3, 4] -}
{- Publish a list of all publications of f. Assume f is helpful. Assume you have xfer() from above. -} f() >x> b.put(x) >> stop ; xfer(b) {- NONRUNNABLE -} {- (1 | 2 | 3) >x> c.put(x) >> stop ; xfer(c) outputs [1,2,3] -}
Related Reference Topics
Related Tutorial Sections