This file contains hidden or 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
(defn all-same-order? [colls] | |
(every? identity (for [a colls b colls] (same-order? a b)))) | |
(all-same-order? [[1 2 3] [1 3 5] [1 2 4] [4 2]]) |
This file contains hidden or 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
(defn same-order? | |
"Returns true if the common elements in coll's a and b are in the samme order." | |
[a b] | |
(= (filter #(some #{%} b) a) | |
(filter #(some #{%} a) b))) |
This file contains hidden or 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
#!/bin/bash | |
# FILE NAME: clj | |
# This clojure script assumes the following directory structure | |
# | |
# ~/ | |
# ~/clojure/ | |
# ~/clojure/classes/ | |
# ~/clojure/libs/ | |
# ~/clojure/source/ | |
# |
This file contains hidden or 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
(defun remove-all (elts list &key (key #'identity) (test #'eql)) | |
"Removes all elements of ELTS from LIST. This is similar to set-difference with the exception | |
that the order of the elements in LIST is preserved." | |
(remove-if #'(lambda (elt) (member (funcall key elt) elts :test test)) list)) | |
(defun all-same-order-p (list-of-lists &key (test #'eql)) | |
"Returns true if the lists in LIST-OF-LISTS are all in the same order." | |
(flet ((same-order-p (list1 list2) | |
(let ((diff (set-exclusive-or list1 list2 :test test))) | |
(equal (remove-all diff list1 :test test) |