0
votes

I'm currently working through clojurecademy and came across this problem which I can't seem to solve -

(= (#_blank (sort (rest (reverse [2 5 4 1 3 6]))))
   (-> [2 5 4 1 3 6] (reverse) (rest) (sort) (#_blank))
   5)

I only need to enter enough to fill in the blank, at first I thought it was just asking me to write what these functions would return, which I think would be (1 2 3 4 5) but that's not correct, I can't figure out why there is a 5 passed in the the equal function, I was thinking maybe I needed to add a function that references 5 from the returned list but I'm not sure how to do that either (without a defined variable) I could be way off...

This is clojurecademy, Problems - Elementary question number 23

1
in case this is what is bothering you, = can test equality on more than 2 arguments (it test if they are all equal) - coredump
I see, but as far as I can tell the first two eval to - (1 2 3 4 5) and the last argument is 5, feeling confused about how they are all supposed to be equal? - Mike Sullivan
Ah I think I see, I have to add a function which takes 5 from the returned list? - Mike Sullivan
Be lazy! just replace the #_blank with (constantly 5) ))) - leetwinski

1 Answers

1
votes

The challenge is to make each expression return 5.

As = can take multiple values for equality, Clojure Academy have included 5 within the check too ensure the two expresions you need to complete also return 5.

I would recommend trying to get this expression to return 5

(#_blank (sort (rest (reverse [2 5 4 1 3 6]))))

then work on the next expression to return 5.