summaryrefslogtreecommitdiff
path: root/demos/chain.apl
blob: e7e1979be97f2b5f826bac57da691aa40377bd5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
⍝ First we define a function which recieves a message,
⍝ and sends one to the task with id ⍵
f←{
        (from msg)←{1 ⍵}⍇⍬
        (1+msg)⍈⍵
      }

⍝ Now start 10000 of those
last←f&'chain'⍣10000⊢⎕self

≢⎕THREADS 0

⍝ Start the chain by sending something to the last one
0 ⍈ last

⎕threads 0 1 2

{1 (2⊃⍵)}⍇0 ⍝ We only pick out the message part, not the sender