X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=assignment10.mdwn;h=8f52ca20370e879efa536b7d720c5a7d21a6c6dd;hp=ad6ebb14e79aebd19f7733a51135b397f540787d;hb=21c2f56ceac1e9445ee7cc8e15786e9521a40b9b;hpb=c42666baade652387ad72d5109eff241c796edfb diff --git a/assignment10.mdwn b/assignment10.mdwn index ad6ebb14..8f52ca20 100644 --- a/assignment10.mdwn +++ b/assignment10.mdwn @@ -9,6 +9,25 @@ > it with. + As Ken Shan points out, this is an instance of the algorithm + for converting name/year citations (like 'v. Montague 1970') + to numerals corresponding to their ('v. [24]'). Except that + bibliograpic numerals don't start with zero. + + Give some thought to efficiency: there are straightforward + solutions that involve traversing the tree once (in order to, + say, construct a suitable mapping from leafs to ints), then + traversing it again to do the conversion. Can you find a + solution that traverses the tree exactly once, replacing each + leaf as soon as you see it? + + Consider a variation in which you must replace each leaf with + is number of occurrences in the tree. Is there any way to do + that with a single traversal? + + You can assume that the tree is leaf-labeled (no labels on the + internal nodes), and that the leafs are, say, chars. + Here is [a hint](/hints/assignment_10_hint). @@ -93,7 +112,19 @@ (insert-co new before after (cdr lst) (lambda (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 and shift instead of having an explicit `k` argument. This will likely be challenging but rewarding. The notes on [[CPS and Continuation Operators]], especially the examples at the end, should be helpful. We are of course also glad to help you out. +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 +and shift instead of having an explicit `k` argument. This will likely +be challenging but rewarding. The notes on [[CPS and Continuation Operators]], especially the examples at the end, should be helpful. We +are of course also glad to help you out. + + Consider adding a special symbol `'#'` (pronounced 'prompt') to the + mini-language such that + + `"ab#cdSef"` ~~> `"abcdcdef"` + + That is, the rule for `'S'` is to copy the preceding string, but + only up to the closest enclosing `'#'` symbol. 7. Can you reimplement your solution to [[assignment9]] using reset and shift?