Hello
I solved all the first steps challenges of this page ( https://exercises.clojure.camp/)
Can anyone give me feedback if I did a good job here.
Code so far: clojure_learning/src/roelof/easy.clj at main · RoelofWobben/clojure_learning · GitHub
Hello
I solved all the first steps challenges of this page ( https://exercises.clojure.camp/)
Can anyone give me feedback if I did a good job here.
Code so far: clojure_learning/src/roelof/easy.clj at main · RoelofWobben/clojure_learning · GitHub
ns
form is duplicated at the top - you can remove the one without :require
(< a 0)
and (> a 0)
can be written as (neg? a)
and (pos? a)
clamp
as (defn clamp [x min-x max-x] (min max-x (min min-x x)))
Other than that, no comments. But I also didn’t try to make sense of what the code actually does
Thanks, I will change that
Sorry your clamp is not working well
FAIL in () (easy.clj:138)
; valid triangle non valid triangle valid triangle on the sides non-valid on one side a triangle test clamp
; expected: (= (clamp 2 1 4) 2)
; actual: (not (= 1 2))
; ❌ FAIL in () (easy.clj:138)
; valid triangle non valid triangle valid triangle on the sides non-valid on one side a triangle test clamp
; expected: (= (clamp 0 1 4) 1)
; actual: (not (= 0 1))
; ❌ FAIL in () (easy.clj:138)
; valid triangle non valid triangle valid triangle on the sides non-valid on one side a triangle test clamp
; expected: (= (clamp 5 1 4) 4)
; actual: (not (= 1 4))
Sorry, a typo. Should be
(defn clamp [x min-x max-x]
(min max-x (max min-x x)))
Thanks, that works
and also thanks for the feedback