ass10 tweaks
authorJim Pryor <profjim@jimpryor.net>
Thu, 23 Dec 2010 17:30:34 +0000 (12:30 -0500)
committerJim Pryor <profjim@jimpryor.net>
Thu, 23 Dec 2010 17:30:34 +0000 (12:30 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
assignment10.mdwn

index f16718d..087b66a 100644 (file)
@@ -114,6 +114,18 @@ Of course, if you need help or want us to review your efforts, we'll be glad to
 
        What would be a helper function you could supply as a `k` that would report `#t` iff the original `lst` contained more instances of some symbol than non-instances?
 
+<!--
+               (define remove-co
+                 (lambda (a lst k)
+                   (cond
+                     ((null? lst)
+                      (k '() '()))
+                     ((eq? (car lst) a)
+                      (remove-co a (cdr lst) (lambda (left right) (k left (cons (car lst) right)))))
+                     (else
+                      (remove-co a (cdr lst) (lambda (left right) (k (cons (car lst) left) right)))))))
+-->
+
 5.     Now we define a function `insert-co` which has the following behavior. It accepts as arguments three symbols, a list, and a handler. The first symbol is inserted before (to the left of) any occurrences in the list of the second symbol, and after (to the right of) any occurrences of the third symbol. The handler is then called with three arguments: the new list (with the insertions made), the number of "to-the-left" insertions that were made, and the number of "to-the-right" insertions that were made.
 
        Here is a partial implementation. You should fill in the blanks. If you get stuck, you can consult the walkthough in _The Little Schemer_, or talk to us.
@@ -130,6 +142,20 @@ Of course, if you need help or want us to review your efforts, we'll be glad to
                      (else
                       (insert-co new before after (cdr lst) (lambda (new-lst lefts rights) ________))))))
 
+<!--
+               (define insert-co
+                 (lambda (new before after lst k)
+                   (cond
+                     ((null? lst)
+                      (k '() 0 0))
+                     ((eq? (car lst) before)
+                      (insert-co new before after (cdr lst) (lambda (new-lst lefts rights) (k (cons new (cons before new-lst)) (succ lefts) rights))))
+                     ((eq? (car lst) after)
+                      (insert-co new before after (cdr lst) (lambda (new-lst lefts rights) (k (cons (after (cons new new-lst))) lefts (succ rights)))))
+                     (else
+                      (insert-co new before after (cdr lst) (lambda (new-lst lefts rights) (k (cons (car lst) new-lst) lefts rights)))))))
+-->
+
 
 6.     Go back to the "abSd" problem we presented in [[From List Zippers to Continuations]]. Consider the "tc" solution which uses
 explicitly passed continuations. Try to reimplement this using reset