diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-03-31 08:11:45 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-03-31 08:11:45 -0700 |
commit | 860628c70a73064d53048fc095c430a0c3df6124 (patch) | |
tree | 40e3e2442eecf89beee317c4fbf39a9f21f2ae33 /065duplex_list.mu | |
parent | daa214478a7c09a996aae7141054d12a481bb392 (diff) | |
download | mu-860628c70a73064d53048fc095c430a0c3df6124.tar.gz |
3808 - 'length' for duplex lists
Diffstat (limited to '065duplex_list.mu')
-rw-r--r-- | 065duplex_list.mu | 12 |
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 |