diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-06-13 16:25:45 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-06-13 16:25:45 -0700 |
commit | 5e15a74f06e19e75954547cadc8bc73f9034727e (patch) | |
tree | 865531ced05be722a67dd874338c791eb4da9622 /073array.mu | |
parent | 29cc15d6b3559221e1147f1a822e10dcb22678e6 (diff) | |
download | mu-5e15a74f06e19e75954547cadc8bc73f9034727e.tar.gz |
3055
Diffstat (limited to '073array.mu')
-rw-r--r-- | 073array.mu | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/073array.mu b/073array.mu deleted file mode 100644 index 8272a865..00000000 --- a/073array.mu +++ /dev/null @@ -1,40 +0,0 @@ -scenario array-from-args [ - run [ - local-scope - x:address:array:character <- new-array 0, 1, 2 - 10:array:character/raw <- copy *x - ] - memory-should-contain [ - 10 <- 3 # array length - 11 <- 0 - 12 <- 1 - 13 <- 2 - ] -] - -# create an array out of a list of scalar args -def new-array -> result:address:array:character [ - local-scope - capacity:number <- copy 0 - { - # while read curr-value - curr-value:character, exists?:boolean <- next-ingredient - break-unless exists? - capacity <- add capacity, 1 - loop - } - result <- new character:type, capacity - rewind-ingredients - i:number <- copy 0 - { - # while read curr-value - done?:boolean <- greater-or-equal i, capacity - break-if done? - curr-value:character, exists?:boolean <- next-ingredient - assert exists?, [error in rewinding ingredients to new-array] - *result <- put-index *result, i, curr-value - i <- add i, 1 - loop - } - return result -] |