about summary refs log tree commit diff stats
path: root/064list.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-03-31 08:11:45 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-03-31 08:11:45 -0700
commit860628c70a73064d53048fc095c430a0c3df6124 (patch)
tree40e3e2442eecf89beee317c4fbf39a9f21f2ae33 /064list.mu
parentdaa214478a7c09a996aae7141054d12a481bb392 (diff)
downloadmu-860628c70a73064d53048fc095c430a0c3df6124.tar.gz
3808 - 'length' for duplex lists
Diffstat (limited to '064list.mu')
-rw-r--r--064list.mu11
1 files changed, 7 insertions, 4 deletions
diff --git a/064list.mu b/064list.mu
index b09cca43..eb6e0dc9 100644
--- a/064list.mu
+++ b/064list.mu
@@ -52,10 +52,13 @@ scenario list-handling [
 def length l:&:list:_elem -> result:num [
   local-scope
   load-ingredients
-  return-unless l, 0
-  rest:&:list:_elem <- rest l
-  length-of-rest:num <- length rest
-  result <- add length-of-rest, 1
+  result <- copy 0
+  {
+    break-unless l
+    result <- add result, 1
+    l <- rest l
+    loop
+  }
 ]
 
 # insert 'x' after 'in'