From 03afc79c9ef6d34ca54511779510836a15016ece Mon Sep 17 00:00:00 2001 From: ninjyni Date: Fri, 30 Dec 2016 11:57:17 +0200 Subject: [PATCH 1/3] exercises 1-2 --- src/predicates.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/predicates.clj b/src/predicates.clj index 158b1ea..b34cf02 100644 --- a/src/predicates.clj +++ b/src/predicates.clj @@ -1,13 +1,13 @@ (ns predicates) (defn sum-f [f g x] - :-) + (+ (f x) (g x))) (defn less-than [n] - :-) + (fn [x] (< x n))) (defn equal-to [n] - :-) + (fn [x] (== x n))) (defn set->predicate [a-set] :-) From d9eadc681c5eb1f9427772ac54acb33aa9790807 Mon Sep 17 00:00:00 2001 From: Nina Tyni Date: Fri, 26 Jan 2018 19:12:38 +0200 Subject: [PATCH 2/3] exercises 3-11 --- src/predicates.clj | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/predicates.clj b/src/predicates.clj index b34cf02..cbcf620 100644 --- a/src/predicates.clj +++ b/src/predicates.clj @@ -10,32 +10,34 @@ (fn [x] (== x n))) (defn set->predicate [a-set] - :-) + (fn [x] (contains? a-set x))) (defn pred-and [pred1 pred2] - :-) + (fn [x] (and (pred1 x) (pred2 x)))) (defn pred-or [pred1 pred2] - :-) + (fn [x] (or (pred1 x) (pred2 x)))) (defn whitespace? [character] (Character/isWhitespace character)) (defn blank? [string] - :-) + (or (nil? string) (every? whitespace? string))) (defn has-award? [book award] - :-) + (contains? (:awards book) award)) (defn HAS-ALL-THE-AWARDS? [book awards] - :-) + (every? (:awards book) awards)) (defn my-some [pred a-seq] - :-) + (let [x (map pred a-seq)] + (first (filter boolean x)))) (defn my-every? [pred a-seq] - :-) + (or (empty? a-seq) (empty? (filter (complement pred) a-seq)))) (defn prime? [n] - :-) + (let [pred (fn [x] (= (mod n x) 0))] + (not (some pred (range 2 n))))) ;^^ From 3d3759e85484c448999b2f8c36277cdce826ae03 Mon Sep 17 00:00:00 2001 From: Nina Tyni Date: Fri, 26 Jan 2018 19:24:52 +0200 Subject: [PATCH 3/3] fix lein command --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 455f3c0..45c29f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: clojure -lein: lein2 -script: lein2 midje :config .midje-grading-config.clj +lein: lein +script: lein midje :config .midje-grading-config.clj jdk: - openjdk7 notifications: