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):

  1. create data structure (such common lisp's hash table) remembering atoms seen
  2. create recursive sub-function actual traversing - walking nested lists , adding new atoms data structure, , if 1 there, returning true

Comments

Popular posts from this blog

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -