annotate samples/testarray.tp @ 178:e823e104b845

Add initial work on bytearrays with support for allocating executable memory
author Mike Pavone <pavone@retrodev.com>
date Sat, 24 Aug 2013 09:55:54 -0700
parents 48daa1d3e052
children 810b6115c1d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39
a997e42b9051 Add foreach method to array and add fib sample that can work in C environment and array example
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
40
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
2 sum <- :arr {
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
3 cursum <- 0
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
4 foreach: arr :idx el {
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
5 cursum <- cursum + el
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
6 }
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
7 cursum
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
8 }
39
a997e42b9051 Add foreach method to array and add fib sample that can work in C environment and array example
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 main <- {
a997e42b9051 Add foreach method to array and add fib sample that can work in C environment and array example
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 foo <- #[42 30 28]
40
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
11 bar <- #[]
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
12 bar append: 30
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
13 bar append: 28
927fd7911a01 Add append message to array
Mike Pavone <pavone@retrodev.com>
parents: 39
diff changeset
14 bar append: 42
82
48daa1d3e052 Update testarray sample to use print:
Mike Pavone <pavone@retrodev.com>
parents: 40
diff changeset
15 print: "" . ((sum: foo) + (sum: bar)) . "\n"
39
a997e42b9051 Add foreach method to array and add fib sample that can work in C environment and array example
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 }
a997e42b9051 Add foreach method to array and add fib sample that can work in C environment and array example
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 }
a997e42b9051 Add foreach method to array and add fib sample that can work in C environment and array example
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18