annotate src/kernel.tp @ 372:e857104bd183

Added reverse method to arrays
author Michael Pavone <pavone@retrodev.com>
date Wed, 12 Aug 2015 19:16:41 -0700
parents 96e21f525b78
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 /*
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 array <- #{
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 new <- {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 length <- 0
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #{
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 each <- :fun {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 repeat: length :idx {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 fun: idx (get: idx)
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 */
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 true <- #{
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 if:else <- :self trueblock :elseblock {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 trueblock:
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 false <- #{
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 if:else <- :self trueblock :elseblock {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 elseblock:
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 filter <- :arr pred {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 output <- arr slice: 0 0
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 each: arr :idx el {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31 if: (pred: el) {
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 output push: el
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 } else: {}
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 }
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 output
96e21f525b78 Forgot to add kernel.tp
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 }