From f9c3b38ffb04b6053d9273614541cbf70d3cdcf8 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Fri, 2 Jul 2010 12:48:02 +0530 Subject: [PATCH] solution to 2.24. Please look at the correctness of the box and arrow diagram --- src/sicp/ex2_24.clj | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/sicp/ex2_24.clj diff --git a/src/sicp/ex2_24.clj b/src/sicp/ex2_24.clj new file mode 100644 index 0000000..b027573 --- /dev/null +++ b/src/sicp/ex2_24.clj @@ -0,0 +1,34 @@ +; -*-text-*- +(comment +(list 1 (list 2 (list 3 4))) +;;=> (1 (2 (3 4))) +) + +;; box and arrow notation + + --- --- --- --- + | | |--> | | \ | + --- --- --- --- + | | + | | + -> 1 | + --- --- --- --- + | | |--> | | \ | + --- --- --- --- + | | + | | + -> 2 | + --- --- --- --- + | | |--> | | \ | + --- --- --- --- + | | + | | + -> 3 -> 4 + +The key to draw box-and-arroy diagram is to look at the list and draw +the outermost level elements in the top and then work innerwards (downwards) +from there. So, (1 (2 (3 4))) has two elements at the top : +1 and (list 2 (list 3 4)) + +(2 (3 4)) has two elements in it: 2 and (list 3 4) and then we have (3 4). +This translated to the above diagram. -- 2.45.2