|
|
1.1 root 1: #
2: # P A R A L L E L E V A L U A T I O N
3: #
4:
5: # This program illustrates an alternative to Icon's normal
6: # last-in, first-out resumption of generators that results
7: # in "cross-product" evaluation of arguments. Here, parallel
8: # evaluation is provided.
9:
10: procedure main()
11: every Parallel{|write,!"abcd",1 to 10}
12: every Parallel{|write,octal(),star("abc")}
13: end
14:
15: procedure star(s)
16: suspend "" | (star(s) || !s)
17: end
18:
19: procedure octal()
20: suspend (0 to 3) || (0 to 7) || (0 to 7)
21: end
22:
23: procedure Parallel(a)
24: local i, x
25: x := list(*a)
26: repeat {
27: every i := 1 to *a do
28: x[i] := @a[i] | fail
29: suspend Call(x)
30: }
31: end
32:
33: procedure Call(a)
34: suspend case *a of {
35: 1 : a[1]()
36: 2 : a[1](a[2])
37: 3 : a[1](a[2],a[3])
38: 4 : a[1](a[2],a[3],a[4])
39: 5 : a[1](a[2],a[3],a[4],a[5])
40: 6 : a[1](a[2],a[3],a[4],a[5],a[6])
41: 7 : a[1](a[2],a[3],a[4],a[5],a[6],a[7])
42: 8 : a[1](a[2],a[3],a[4],a[5],a[6],a[7],a[8])
43: 9 : a[1](a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9])
44: 10 : a[1](a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10])
45: default : stop("Call : too many args.")
46: }
47: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.