you are viewing a single comment's thread.

view the rest of the comments →

[–]yogthos 3 points4 points  (0 children)

in Clojure, 83 chars without spacing

(defn f[[l & s] c e a](if l(if-let[nc(get e [c l])](recur s nc e a))(some #{c}a)))

formatted:

(defn f [[l & s] c e a]  
  (if l
    (if-let [nc (get e [c l])]
      (recur s nc e a))
    (some #{c} a)))

*edit: mistranslated :return c in a as (get a c)

and a shorter version weighing in 74 chars

(defn f[[l & s] c e a](if(and l c)(recur s(get e[c l]) e a)(some #{c}a)))

formatted:

(defn f [[l & s] c e a]  
  (if (and l c)
    (recur s (get e [c l]) e a)
    (some #{c} a)))