Ad
  • Default User Avatar

    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))
    )

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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))
    )

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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.

  • Default User Avatar

    @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?

  • Default User Avatar

    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 ==.