From 67db19a05335c7fbea3ad6737303c8848fd39e74 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 15 Dec 2015 14:32:47 -0800 Subject: 2545 update html --- html/075duplex_list.mu.html | 97 ++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 50 deletions(-) (limited to 'html/075duplex_list.mu.html') diff --git a/html/075duplex_list.mu.html b/html/075duplex_list.mu.html index f2094cde..4a0abcbb 100644 --- a/html/075duplex_list.mu.html +++ b/html/075duplex_list.mu.html @@ -40,17 +40,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } prev:address:duplex-list:_elem ] -recipe push x:_elem, in:address:duplex-list:_elem -> result:address:duplex-list:_elem [ +# should I say in/contained-in:result, allow ingredients to refer to products? +recipe push x:_elem, in:address:duplex-list:_elem -> in:address:duplex-list:_elem [ local-scope load-ingredients - result <- new {(duplex-list _elem): type} + result:address:duplex-list:_elem <- new {(duplex-list _elem): type} val:address:_elem <- get-address *result, value:offset *val <- copy x next:address:address:duplex-list:_elem <- get-address *result, next:offset *next <- copy in - reply-unless in - prev:address:address:duplex-list:_elem <- get-address *in, prev:offset - *prev <- copy result + { + break-unless in + prev:address:address:duplex-list:_elem <- get-address *in, prev:offset + *prev <- copy result + } + reply result # needed explicitly because we need to replace 'in' with 'result' ] recipe first in:address:duplex-list:_elem -> result:_elem [ @@ -60,14 +64,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } result <- get *in, value:offset ] -recipe next in:address:duplex-list:_elem -> result:address:duplex-list:_elem [ +recipe next in:address:duplex-list:_elem -> result:address:duplex-list:_elem/contained-in:in [ local-scope load-ingredients reply-unless in, 0 result <- get *in, next:offset ] -recipe prev in:address:duplex-list:_elem -> result:address:duplex-list:_elem [ +recipe prev in:address:duplex-list:_elem -> result:address:duplex-list:_elem/contained-in:in [ local-scope load-ingredients reply-unless in, 0 @@ -116,11 +120,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -# Inserts 'x' after 'in'. Returns some pointer into the list. -recipe insert x:_elem, in:address:duplex-list:_elem -> new-node:address:duplex-list:_elem [ +# insert 'x' after 'in' +recipe insert x:_elem, in:address:duplex-list:_elem -> in:address:duplex-list:_elem [ local-scope load-ingredients - new-node <- new {(duplex-list _elem): type} + new-node:address:duplex-list:_elem <- new {(duplex-list _elem): type} val:address:_elem <- get-address *new-node, value:offset *val <- copy x next-node:address:duplex-list:_elem <- get *in, next:offset @@ -134,11 +138,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } y <- get-address *new-node, next:offset *y <- copy next-node # if next-node is not null - reply-unless next-node, new-node + reply-unless next-node # next-node.prev = new-node y <- get-address *next-node, prev:offset *y <- copy new-node - reply new-node # just signalling something changed; don't rely on the result ] scenario inserting-into-duplex-list [ @@ -219,7 +222,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 1:address:duplex-list:character <- push 3, 0 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character - 2:address:duplex-list:character <- insert 6, 1:address:duplex-list:character + 1:address:duplex-list:character <- insert 6, 1:address:duplex-list:character # check structure like before 2:address:duplex-list:character <- copy 1:address:duplex-list:character 3:character <- first 2:address:duplex-list:character @@ -249,38 +252,37 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -# Removes 'in' from its surrounding list. Returns some valid pointer into the -# rest of the list. +# remove 'x' from its surrounding list 'in' # -# Returns null if and only if list is empty. Beware: in that case any pointers -# to the head are now invalid. -recipe remove in:address:duplex-list:_elem -> next-node:address:duplex-list:_elem [ +# Returns null if and only if list is empty. Beware: in that case any other +# pointers to the head are now invalid. +recipe remove x:address:duplex-list:_elem/contained-in:in, in:address:duplex-list:_elem -> in:address:duplex-list:_elem [ local-scope load-ingredients - # if 'in' is null, return - reply-unless in, in - next-node:address:duplex-list:_elem <- get *in, next:offset - prev-node:address:duplex-list:_elem <- get *in, prev:offset - # null in's pointers - x:address:address:duplex-list:_elem <- get-address *in, next:offset - *x <- copy 0 - x <- get-address *in, prev:offset - *x <- copy 0 + # if 'x' is null, return + reply-unless x + next-node:address:duplex-list:_elem <- get *x, next:offset + prev-node:address:duplex-list:_elem <- get *x, prev:offset + # null x's pointers + tmp:address:address:duplex-list:_elem <- get-address *x, next:offset + *tmp <- copy 0 + tmp <- get-address *x, prev:offset + *tmp <- copy 0 + # if next-node is not null, set its prev pointer { - # if next-node is not null break-unless next-node - # next-node.prev = prev-node - x <- get-address *next-node, prev:offset - *x <- copy prev-node + tmp <- get-address *next-node, prev:offset + *tmp <- copy prev-node } + # if prev-node is not null, set its next pointer and return { - # if prev-node is not null break-unless prev-node - # prev-node.next = next-node - x <- get-address *prev-node, next:offset - *x <- copy next-node - reply prev-node + tmp <- get-address *prev-node, next:offset + *tmp <- copy next-node + reply } + # if prev-node is null, then we removed the node at 'in' + # return the new head rather than the old 'in' reply next-node ] @@ -290,7 +292,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character 2:address:duplex-list:character <- next 1:address:duplex-list:character # 2 points at second element - 2:address:duplex-list:character <- remove 2:address:duplex-list:character + 1:address:duplex-list:character <- remove 2:address:duplex-list:character, 1:address:duplex-list:character 3:boolean <- equal 2:address:duplex-list:character, 0 # check structure like before 2:address:duplex-list:character <- copy 1:address:duplex-list:character @@ -317,8 +319,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 1:address:duplex-list:character <- push 3, 0 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character - # removing from head? return value matters. - 1:address:duplex-list:character <- remove 1:address:duplex-list:character + 1:address:duplex-list:character <- remove 1:address:duplex-list:character, 1:address:duplex-list:character # check structure like before 2:address:duplex-list:character <- copy 1:address:duplex-list:character 3:character <- first 2:address:duplex-list:character @@ -346,7 +347,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } # delete last element 2:address:duplex-list:character <- next 1:address:duplex-list:character 2:address:duplex-list:character <- next 2:address:duplex-list:character - 2:address:duplex-list:character <- remove 2:address:duplex-list:character + 1:address:duplex-list:character <- remove 2:address:duplex-list:character, 1:address:duplex-list:character 3:boolean <- equal 2:address:duplex-list:character, 0 # check structure like before 2:address:duplex-list:character <- copy 1:address:duplex-list:character @@ -371,20 +372,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } scenario removing-from-singleton-list [ run [ 1:address:duplex-list:character <- push 3, 0 - 2:address:duplex-list:character <- remove 1:address:duplex-list:character - 3:address:duplex-list:character <- get *1:address:duplex-list:character, next:offset - 4:address:duplex-list:character <- get *1:address:duplex-list:character, prev:offset + 1:address:duplex-list:character <- remove 1:address:duplex-list:character, 1:address:duplex-list:character ] memory-should-contain [ - 2 <- 0 # remove returned null - 3 <- 0 # removed node is also detached - 4 <- 0 + 1 <- 0 # back to an empty list ] ] # remove values between 'start' and 'end' (both exclusive) # also clear pointers back out from start/end for hygiene -recipe remove-between start:address:duplex-list:_elem, end:address:duplex-list:_elem -> start:address:duplex-list:_elem [ +recipe remove-between start:address:duplex-list:_elem, end:address:duplex-list:_elem/contained-in:start -> start:address:duplex-list:_elem [ local-scope load-ingredients reply-unless start @@ -491,8 +488,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -# Inserts list beginning at 'new' after 'in'. Returns some pointer into the list. -recipe insert-range in:address:duplex-list:_elem, start:address:duplex-list:_elem -> in:address:duplex-list:_elem [ +# insert list beginning at 'new' after 'in' +recipe insert-range in:address:duplex-list:_elem, start:address:duplex-list:_elem/contained-in:in -> in:address:duplex-list:_elem [ local-scope load-ingredients reply-unless in @@ -518,7 +515,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *dest <- copy in ] -recipe append in:address:duplex-list:_elem, new:address:duplex-list:_elem -> in:address:duplex-list:_elem [ +recipe append in:address:duplex-list:_elem, new:address:duplex-list:_elem/contained-in:in -> in:address:duplex-list:_elem [ local-scope load-ingredients last:address:duplex-list:_elem <- last in -- cgit 1.4.1-2-gfad0