Skip to content

Commit

Permalink
Added empty #69
Browse files Browse the repository at this point in the history
  • Loading branch information
erlis committed Jan 26, 2015
1 parent 780056d commit 78c7414
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions answers/src/answers/core.clj
Expand Up @@ -85,4 +85,5 @@
(show medium/black-box-testing medium/black-box-testing-answer)
(show easy/greatest-common-divisor easy/greatest-common-divisor-answer)
(show medium/prime-numbers medium/prime-numbers-answer)
(show medium/merge-with-a-function medium/merge-with-a-function-answer)
)
17 changes: 17 additions & 0 deletions answers/src/answers/medium.clj
Expand Up @@ -2,6 +2,23 @@
(:require [clojure.string]
[clojure.test :refer [is]]))

(defn merge-with-a-function
"Write a function which takes a function f and a variable number of maps. Your function should return a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) should be combined with the mapping in the result by calling (f val-in-result val-in-latter)
SPECIAL RESTRICTIONS: merge-with"
[__]
(is (= (__ * {:a 2, :b 3, :c 4} {:a 2} {:b 2} {:c 5})
{:a 4, :b 6, :c 20}))
(is (= (__ - {1 10, 2 20} {1 3, 2 10, 3 15})
{1 7, 2 10, 3 15}))
(is (= (__ concat {:a [3], :b [6]} {:a [4 5], :c [8 9]} {:b [7]})
{:a [3 4 5], :b [6 7], :c [8 9]}))
)

(defn merge-with-a-function-answer
[f & colls]
)


(defn prime-numbers
"Write a function which returns the first x number of prime numbers"
[__]
Expand Down

0 comments on commit 78c7414

Please sign in to comment.