annotate samples/testarray.tp @ 366:810b6115c1d4

Add a pop method to array
author Michael Pavone <pavone@retrodev.com>
date Sat, 08 Aug 2015 21:13:26 -0700
parents 48daa1d3e052
children
rev   line source
pavone@39 1 #{
pavone@40 2 sum <- :arr {
pavone@40 3 cursum <- 0
pavone@40 4 foreach: arr :idx el {
pavone@40 5 cursum <- cursum + el
pavone@40 6 }
pavone@40 7 cursum
pavone@40 8 }
pavone@39 9 main <- {
pavone@39 10 foo <- #[42 30 28]
pavone@40 11 bar <- #[]
pavone@40 12 bar append: 30
pavone@40 13 bar append: 28
pavone@40 14 bar append: 42
pavone@82 15 print: "" . ((sum: foo) + (sum: bar)) . "\n"
pavone@366 16 val <- bar pop
pavone@366 17 print: "popped off: " . val . ", new length: " . (bar length) . "\n"
pavone@39 18 }
pavone@39 19 }
pavone@39 20