Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created September 7, 2016 23:05
Show Gist options
  • Save amalloy/c616848d75ff378ecce460dc443937d6 to your computer and use it in GitHub Desktop.
Save amalloy/c616848d75ff378ecce460dc443937d6 to your computer and use it in GitHub Desktop.
(let [[a b c] (repeatedly gensym)
e1 [a b]
e2 [a c]]
(fn [x]
(let [y (conj x e1 e1 e2)
diff (- (count y) (count x))]
(condp = diff
1 :map
2 :set
(if (= (first y) e2)
:list
:vector)))))
@HerbM
Copy link

HerbM commented Sep 7, 2016

;;;My solution is similar but quite different too:

(defn tipe [s]
  (let [sym1  (gensym) sym2 (gensym) 
        sym3  (gensym) s12  (conj s {sym1 sym2}) 
        s1221 (conj (conj s {sym2 sym1}) s12)]
  (if (get s12 sym1) :map
      (if (get s12 {sym1 sym2}) :set      
          (if (= (first s1221) s12) :list :vector)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment