Skip to content

Instantly share code, notes, and snippets.

(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]])
(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)))
#!/bin/bash
# FILE NAME: clj
# This clojure script assumes the following directory structure
#
# ~/
# ~/clojure/
# ~/clojure/classes/
# ~/clojure/libs/
# ~/clojure/source/
#
(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)