Skip to content

Commit

Permalink
Add q59
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Aug 30, 2024
1 parent 96cbeae commit a49d057
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ex/q059.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
;; https://4clojure.oxal.org/#/problem/059

(ns ex.q059)

(defn ans
"Problem 59, Juxtaposition. restrictions: juxt"
([& fns] (fn [& xs] (into [] (map #(apply % xs) fns)))))
13 changes: 13 additions & 0 deletions test/ex/q059_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
;; https://4clojure.oxal.org/#/problem/059

(ns ex.q059-test
(:require [clojure.test :as t]
[ex.q059 :as sut]))

(t/deftest test-q59
(t/testing "Problem 59, Juxtaposition"
(t/is (= [6] ((sut/ans +) 1 2 3)))
(t/is (= [21 6 1] ((sut/ans + max min) 2 3 5 1 6 4)))
(t/is (= ["HELLO" 5] ((sut/ans #(.toUpperCase %) count) "hello")))
(t/is (= [2 6 4] ((sut/ans :a :c :b) {:a 2, :b 4, :c 6, :d 8 :e 10})))
))

0 comments on commit a49d057

Please sign in to comment.