Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/dbyrne/4clojure into dev…
Browse files Browse the repository at this point in the history
…elop
  • Loading branch information
gigasquid committed Apr 28, 2011
2 parents c878918 + 0705010 commit f6f0d1f
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/foreclojure/data_set.clj
Expand Up @@ -658,6 +658,31 @@
:tags ["medium" "seqs" "core-functions"]
:tests ["(= (__ #(> % 5) #{1 3 6 8}) {false [1 3], true [6 8]})"
"(= (__ #(apply / %) [[1 2] [2 4] [4 6] [3 6]])\n {1/2 [[1 2] [2 4] [3 6]], 2/3 [[4 6]]})"
"(= (__ count [[1] [1 2] [3] [1 2 3] [2 3]])\n {1 [[1] [3]], 2 [[1 2] [2 3]], 3 [[1 2 3]]})"]})))
"(= (__ count [[1] [1 2] [3] [1 2 3] [2 3]])\n {1 [[1] [3]], 2 [[1 2] [2 3]], 3 [[1 2 3]]})"]})

(load-problems)
(insert! :problems
{:_id 64
:title "Intro to reduce"
:times-solved 0
:description "<a href='http://clojuredocs.org/clojure_core/clojure.core/reduce'>Reduce</a> takes a 2 argument fuction and and an optional starting value. It then applies the function to the first 2 items in the sequence (or the starting value and the first element of the sequence). In the next iteration the function will be called on the previous return value and the next item from the sequence, thus reducing the entire collection to one value. Don't worry, it's not really that complicated."
:tags ["easy" "core-functions" "reduce"]
:tests ["(= 15 (reduce __ [1 2 3 4 5]))"
"(= 0 (reduce __ []))"
"(= 6 (reduce __ 1 [2 3]))"]})

(insert! :problems
{:_id 65
:title "Black box testing"
:times-solved 0
:description "Clojure has many sequence types, which act in subtly different ways. The core functions typically convert them into a uniform \"sequence\" type and work with them that way, but it can be important to understand the behavioral and performance differences so that you know which kind is appropriate for your application.<br />Write a function which takes a collection and returns one of :map, :set, :list, or :vector - describing the type of collection it was given.<br />You won't be allowed to inspect their class or use the built-in predicates like list? - the point is to poke at them and understand their behavior."
:tags ["medium" "seqs" "testing"]
:tests ["(= :map (__ {:a 1, :b 2}))"
"(= :list (__ (range (rand-int 20))))"
"(= :vector (__ [1 2 3 4 5 6]))"
"(= :set (__ #{10 (rand-int 5)}))"]
:restricted (map str '[class type Class vector? sequential?
list? seq? map? set? getClass])})

))

(load-problems)

0 comments on commit f6f0d1f

Please sign in to comment.