diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-09-25 21:20:49 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-09-25 21:20:49 -0700 |
commit | c0d61295ed3575cfea7d2a22d81bae93c6009308 (patch) | |
tree | 42fc40d4ce6da540c9fa75d5e74ec75e5c313a7b /065duplex_list.mu | |
parent | 409237204368205a06e2b82fcab26b0a290d7412 (diff) | |
download | mu-c0d61295ed3575cfea7d2a22d81bae93c6009308.tar.gz |
4008
Allow list `push` operation to save result in a new list rather than mutate the existing list.
Diffstat (limited to '065duplex_list.mu')
-rw-r--r-- | 065duplex_list.mu | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/065duplex_list.mu b/065duplex_list.mu index 97541f33..30552fb6 100644 --- a/065duplex_list.mu +++ b/065duplex_list.mu @@ -6,17 +6,13 @@ container duplex-list:_elem [ prev:&:duplex-list:_elem ] -# should I say in/contained-in:result, allow ingredients to refer to products? -def push x:_elem, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [ +def push x:_elem, in:&:duplex-list:_elem/contained-in:result -> result:&:duplex-list:_elem [ local-scope load-ingredients result:&:duplex-list:_elem <- new {(duplex-list _elem): type} *result <- merge x, in, 0 - { - break-unless in - *in <- put *in, prev:offset, result - } - return result # needed explicitly because we need to replace 'in' with 'result' + return-unless in + put *in, prev:offset, result ] def first in:&:duplex-list:_elem -> result:_elem [ |