Hi Roelof,
I start the 4Clojure exercises and I did a little project so I can keep a
record of my solutions. It's really simple but also I've found it really
helpful to see where my errors are.
You can fork it from here... if you want.
https://github.com/erlis/4Clojure
You only have there the f
Remember that indexes work from zero. So if you have a collection of 3
elements:
(nth ["a" "b" "c"] 2) => "c"
(nth ["a" "b" "c"] 1) => "b"
(nth ["a" "b" "c"] 0) => "a"
I'd encourage you to open a REPL and try the solution you have to see what
you get if you get stuck. Often some
oke,
Then I think I have to work with a if then :
The second test is already a vector but the thirth not
(= (__ ["a" "b" "c"]) "b")
(= (__ [[1 2] [3 4]]) [1 2])
I tried already the nth but I was also failing on the first. I think
because of count because you cannot know how many values you
Roelof,
The whole point of something like 4clojure is for you to try to understand
how things work and learn how to fix the errors that happen along the way.
Open a repl and see what the error tells you. Also, you should have the
clojure cheat sheet open to help you find what each function does
Also, don't forget that vectors are zero indexed, so (- (count v) 1) will
give you the last element, not the second last.
Cheers,
James
On Sunday, May 4, 2014 4:49:45 PM UTC+2, Lee wrote:
>
>
>
> On May 4, 2014, at 10:42 AM, Roelof Wobben >
> wrote:
>
> > For 4clojure I have to find the second
On May 4, 2014, at 10:42 AM, Roelof Wobben wrote:
> For 4clojure I have to find the second to last item.
>
> So I did this:
>
> (fn secondlast [v]
> (get v (-(count v)1)))
>
> Now it's only failing at this test : (= (__ (list 1 2 3 4 5)) 4)
>
> Can anyone tell me where I did take the wr
Hello,
For 4clojure I have to find the second to last item.
So I did this:
(fn secondlast [v]
(get v (-(count v)1)))
Now it's only failing at this test : (= (__ (list 1 2 3 4 5)) 4)
Can anyone tell me where I did take the wrong way.
Roelof
--
You received this message because you are