Finding duplicate atoms in possibly nested lists in LISP -
i trying figure out how find duplicate atom in possibly nested lists. have been trying figure out day. if please give me logic, great because want learn.
basically
(finddup '(a b b))
return t
(finddup '(a c ((d (f a)) s)))
return t
the easiest , efficient way following (pseudocode):
- create data structure (such common lisp's hash table) remembering atoms seen
- create recursive sub-function actual traversing - walking nested lists , adding new atoms data structure, , if 1 there, returning true
Comments
Post a Comment