X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=miscellaneous_lambda_challenges_and_advanced_topics.mdwn;h=c706ec184e38b8f936f030d5fefcd48168ce254f;hp=173ddbe3f782544b9cfb0f3d15b19c4b92b45a4d;hb=d46bf9ad6b6516143bbe3dc00acff08b70b6dbd3;hpb=372c27cbb4d670940cfc22c427e3b12d87d3b9df diff --git a/miscellaneous_lambda_challenges_and_advanced_topics.mdwn b/miscellaneous_lambda_challenges_and_advanced_topics.mdwn index 173ddbe3..c706ec18 100644 --- a/miscellaneous_lambda_challenges_and_advanced_topics.mdwn +++ b/miscellaneous_lambda_challenges_and_advanced_topics.mdwn @@ -548,19 +548,19 @@ So the inner node doesn't need its own independent label. Similarly, the leaf-labeled tree: - + + . / \ - + 3 + . 3 / \ 1 2 can be thought of as a data structure of the form: - Node (its_left_subtree, its_right_subtree) | Leaf (its_label) + Leaf (its_label) | Non_leaf (its_left_subtree, its_right_subtree) and that could be implemented in v2 form as: - the_tree (\left right. node_handler) (\label. lead_handler) + the_tree (\left right. non_leaf_handler) (\label. leaf_handler) And the node-labeled tree: @@ -574,11 +574,11 @@ So the inner node doesn't need its own independent label. can be thought of as a data structure of the form: - Node (its_left_subtree, its_label, its_right_subtree) | Leaf + Leaf | Non_leaf (its_left_subtree, its_label, its_right_subtree) and that could be implemented in v2 form as: - the_tree (\left label right. node_handler) leaf_result + the_tree (\left label right. non_leaf_handler) leaf_result What would correspond to "folding" a function `f` and base value `z` over a @@ -607,7 +607,7 @@ So the inner node doesn't need its own independent label. the label of the root (topmost node) of a tree; extracting the left subtree of a node; and so on. - Think about different ways you might implement v3-style trees. + Think about different ways you might implement leaf-labeled trees. If you had one tree and wanted to make a larger tree out of it, adding in a new element, how would you do that? @@ -678,7 +678,7 @@ the tree to be relatively "balanced", like this: you're building pretty "balanced" in this way? This is a large topic in computer science. There's no need for you to learn -any of the various strategies that they've developed for doing this. But +the various strategies that they've developed for doing this. But thinking in broad brush-strokes about what strategies might be promising will help strengthen your understanding of trees, and useful ways to implement them in a purely functional setting like the lambda calculus.