Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

'Doing a binary tree'? You mean visiting every node?

  define walk-tree (tree fn &optional remaining-branches)
    match tree
      (Leaf l) ->
        funcall fn l
        if remaining-branches
          walk-tree (first remaining-branches) fn (rest remaining-branches)
      (Tree t r l) ->
        funcall fn t
        walk-tree r fn (push l remaining-branches)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: