code_junkie

How can a simple tree algorithm be coded in a functional language?

Nov 10th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. (defun buildtree (wordlist) ...code to build tree recursively returns the tree...)
  2. (define lookup (tree word) ...code to look up word using tree, returns t or nil...)
  3.  
  4. (defun lookupmany (tree querylist)
  5. (if (eq querylist nil)
  6. nil
  7. (cons (lookup tree (car querylist)) (lookupmany tree (cdr querylist))
  8. )
  9. )
  10.  
  11. (defun main (wordlist querylist) ; the main entry point
  12. (lookupmany (buildtree wordlist) querylist)
  13. )
Add Comment
Please, Sign In to add comment