container list [
value:location
next:address:list
]
recipe push [
local-scope
x:location <- next-ingredient
in:address:list <- next-ingredient
result:address:list <- new list:type
val:address:location <- get-address *result, value:offset
*val <- copy x
next:address:address:list <- get-address *result, next:offset
*next <- copy in
reply result
]
recipe first [
local-scope
in:address:list <- next-ingredient
result:location <- get *in, value:offset
reply result
]
recipe rest [
local-scope
in:address:list <- next-ingredient
result:address:list <- get *in, next:offset
reply result
]
scenario list-handling [
run [
1:address:list <- copy 0
1:address:list <- push 3, 1:address:list
1:address:list <- push 4, 1:address:list
1:address:list <- push 5, 1:address:list
2:number <- first 1:address:list
1:address:list <- rest 1:address:list
3:number <- first 1:address:list
1:address:list <- rest 1:address:list
4:number <- first 1:address:list
1:address:list <- rest 1:address:list
]
memory-should-contain [
1 <- 0
2 <- 5
3 <- 4
4 <- 3
]
]