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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -