Contents    Page-10    Prev    Next    Page+10    Index   

Linked List Tree

We can think of a linked list as a tree. The first node of the list contains the contents of the node, and the rest of the list is a list of the children. The children, in turn, can be lists; a non-list is a leaf node. This is similar to first-child / next-sibling.


(= Y (+ (* M X) B))     (op lhs rhs)


(defn op [e] (first e))     ; operator
(defn lhs [e] (second e))   ; left-hand side
(defn rhs [e] (first (rest (rest e))))  ; right