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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -