Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call 0 arity function when all arguments to ignoring-nil are nil #39

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/flatland/useful/fn.clj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
(f a)
(f a b))))
([a b & more]
(when-let [items (seq (remove nil? (list* a b more)))]
(let [items (seq (remove nil? (list* a b more)))]
(apply f items)))))

(defn key-comparator
Expand Down
5 changes: 4 additions & 1 deletion test/flatland/useful/fn_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@
(is (= 5 (thrush 1 inc inc inc inc))))

(deftest test-ignoring-nils
(is (= 6 ((ignoring-nils +) 1 nil 2 nil nil 3))))
(is (= 6 ((ignoring-nils +) 1 nil 2 nil nil 3)))
(is (= 0 ((ignoring-nils +) nil nil)))
(is (= 0 ((ignoring-nils +) nil nil nil)))
(is (= 0 ((ignoring-nils +) nil nil nil nil))))

(deftest test-key-comparator
(let [subtract-comparator-fn-breaks-on-this [2147483650 2147483651
Expand Down