about summary refs log tree commit diff stats
path: root/065duplex_list.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 /065duplex_list.mu
parentdaa214478a7c09a996aae7141054d12a481bb392 (diff)
downloadmu-860628c70a73064d53048fc095c430a0c3df6124.tar.gz
3808 - 'length' for duplex lists
Diffstat (limited to '065duplex_list.mu')
-rw-r--r--065duplex_list.mu12
1 files changed, 12 insertions, 0 deletions
diff --git a/065duplex_list.mu b/065duplex_list.mu
index fa3527fe..58b5468e 100644
--- a/065duplex_list.mu
+++ b/065duplex_list.mu
@@ -83,6 +83,18 @@ scenario duplex-list-handling [
   ]
 ]
 
+def length l:&:duplex-list:_elem -> result:num [
+  local-scope
+  load-ingredients
+  result <- copy 0
+  {
+    break-unless l
+    result <- add result, 1
+    l <- next l
+    loop
+  }
+]
+
 # insert 'x' after 'in'
 def insert x:_elem, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [
   local-scope