Last active
January 7, 2016 16:40
-
-
Save kkrzeminski/ed45f904658658825925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fn sym | |
([tree] | |
(or (nil? tree) | |
(and | |
(coll? tree) | |
(= 3 (count tree)) | |
(sym (nth tree 1)) | |
(sym (nth tree 2)) | |
(or (and | |
(coll? (nth tree 1)) | |
(coll? (nth tree 2)) | |
(sym (nth tree 1) (nth tree 2))) | |
(and | |
(not (coll? (nth tree 1))) | |
(not (coll? (nth tree 2))) | |
(= (nth tree 1) (nth tree 2))) | |
) | |
) | |
) | |
) | |
([tree1 tree2] | |
(and | |
(= (first tree1) (first tree2)) | |
(= (count (rest tree1)) (count (rest tree2))) | |
(every? | |
#(or | |
(and | |
(not (coll? (first %))) | |
(not (coll? (second %))) | |
(= (first %) (second %)) | |
) | |
(and | |
(coll? (first %)) | |
(coll? (second %)) | |
(sym (first %)) | |
(sym (second %)) | |
(sym (first %) (second %)) | |
) | |
) | |
(map | |
#(vector %1 %2) | |
(rest tree1) | |
;; czy to jest wystarczajace ? | |
(reverse (rest tree2)) | |
) | |
) | |
) | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment