File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626 query-args (mapv replace-question-mark-with-gensym args)]
2727 {:query-args query-args
2828 :function-args (distinct query-args)
29- :display-args (distinct-except args #{'?})}))
29+ :display-args (distinct-except #{'?} args )}))
3030
3131(defn- fn-symbol
3232 " Attach metadata (docstring/argument lists) to the given symbol."
Original file line number Diff line number Diff line change 1010
1111(ann distinct-except
1212 (All [x]
13- [( Option ( Seq x)) (Option (Set x)) -> (Option (Seq x))]))
13+ [[x -> Boolean] (Option (Seq x)) -> (Option (Seq x))]))
1414(defn distinct-except
15- " Same as distinct, but keeps duplicates from the exceptions set."
16- [coll exceptions]
17- {:pre [(coll? coll)
18- (set? exceptions)]}
19- (let [step (fn step [xs seen]
20- (lazy-seq
21- ((fn [[f :as xs] seen]
22- (when-let [s (seq xs)]
23- (if (and (contains? seen f)
24- (not (exceptions f)))
25- (recur (rest s) seen)
26- (cons f (step (rest s) (conj seen f))))))
27- xs seen)))]
28- (step coll #{})))
15+ " Same as distinct, but keeps duplicates if they pass exception?"
16+ [exception? [head & tail :as coll]]
17+ (lazy-seq
18+ (when head
19+ (cons head
20+ (distinct-except exception?
21+ (if (exception? head)
22+ tail
23+ (remove (partial = head) tail)))))))
2924
3025(ann whitespace?
3126 (IFn [nil -> false ]
Original file line number Diff line number Diff line change 66; ;; Test distinct-except
77(let [coll '[a b c a b]]
88 (expect '[a b c a]
9- (distinct-except coll #{'a}))
9+ (distinct-except #{'a} coll ))
1010 (expect '[a b c b]
11- (distinct-except coll #{'b}))
11+ (distinct-except #{'b} coll ))
1212 (expect '[a b c]
13- (distinct-except coll #{'c})))
13+ (distinct-except #{'c} coll )))
1414
1515; ;; Test underscores-to-dashes
1616(do-template [input output]
You can’t perform that action at this time.
0 commit comments