Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
The tests trivially pass as written. They should look like this (note I've added an =)
(deftest string-to-number-test
(is (= (string-to-number "1234") 1234))
(is (= (string-to-number "605") 605))
(is (= (string-to-number "1405") 1405))
(is (= (string-to-number "-7") -7))
)
This comment is hidden because it contains spoiler information about the solution
The example Clojure tests are misleading. They will pass with the most trivial implementation (as long as the functions are defined).
(deftest example-tests
(is (head [5 1]) 6)
(is (tail [1]) [])
(is (init [1 5 7 9]) [1 5 7])
(is (last_ [7 2]) 2)
)
They should be
(deftest example-tests-fixed
(is (= (head [5 1]) 6))
(is (= (tail [1]) []))
(is (= (init [1 5 7 9]) [1 5 7]))
(is (= (last_ [7 2]) 2))
)
This comment is hidden because it contains spoiler information about the solution
Update: I've confirmed that this is solvable in JS. However, I still don't see how this can be solved in Coffeescript due to differences in the language. I'll explain more in my next post and mark it as a spoiler.
@osuushi Thanks for your question. I tried the Coffeescript solution. I also double checked it was not working at http://coffeescript.org/. I must be missing something! Can I send you a gist of what I tried?
I'm so confused. I struggled with this for a long time and finally gave up and looked at the answers. I must be missing something, but the solutions don't even work for me! I've copy/pasted in the top solution and the first test expectation and it fails. I don't want to say too much, but the failing assertion concerns ==.