(testing "zipmap"
(is (= {:a 1 :b 2} (zipmap [:a :b] '(1 2))))
(is (= {3 1, 2 2, 1 3} (zipmap [1 2 3] [3 2 1])))
(is (= {} (zipmap [] [:a :b])))
(is (= {2 :b, 1 :a} (zipmap [1 2 3] [:a :b])))
I solved top 4 questions. But I could not figure out the last one. We need to fill the zipmap part.(I put 2 question marks there). The question is what we need to put there to get this output:
{:list '() :map {} :vector [] :set #{}}
(is (= {:list '() :map {} :vector [] :set #{}} (zipmap ? ? )))))
This is actually a part of my homework but I really want to know the answer.
Thank you,
zipmap takes two sequences, one containing all the keys, and the other containing all the values. It produces a map where each key matches the value in the same position in the other list
user> (zipmap [:list :map :vector :set] [`() {} [] #{}])
{:set #{}, :vector [], :map {}, :list ()}
In this case, your being asked to provide a sequence of keywords and a sequence of empty examples of different types of collections to produce a map of keywords to an example of a collection.