So I only recently understood closures, actually only made sense after my attempts. Though, if I may ask, how does the lambda function relate to closures? I'm in python I should add.
There were no test cases provided for Ruby. I used:
three = always(3)
Test.assert_equals(three.call, 3, "Expected: 3, got #{three.call}")
When submitting, I get this error:
`always': wrong number of arguments (given 0, expected 1) (ArgumentError)
from `<main>'
Is there a test for ruby, currently? I'm new to the functional side of Ruby, so I appreciated this Kata, but I don't know if it is finished on the Ruby side.
Why do you use () (type Unit) for the argument of the returned function? Only one value is unit : () (denoted by the same thing as the type). So actually the returned function will only take () to the given value. I think, the intention was Int -> a -> Int (for any a).
Ie with your type this wouldn't type check: (always 3) 5 only this would: (always 3) ()
The test case implies that no arguments will be passed to this new function. Correct behavior of the returned function in the case of arguments passed should be explicitly mentioned in the instructions.
C++ Translation.
This comment is hidden because it contains spoiler information about the solution
Returning a closure is not a novel kata idea.
So I only recently understood closures, actually only made sense after my attempts. Though, if I may ask, how does the lambda function relate to closures? I'm in python I should add.
Groovy translation kumited. Please review and approve. Thanks, suic
There were no test cases provided for Ruby. I used:
When submitting, I get this error:
Is there a test for ruby, currently? I'm new to the functional side of Ruby, so I appreciated this Kata, but I don't know if it is finished on the Ruby side.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
[all languages]
You could note that this kind of a construction is called a closure.
It would make it easier for beginners to find and learn about this.
This comment is hidden because it contains spoiler information about the solution
I'm talking about haskell:
Why do you use
()
(type Unit) for the argument of the returned function? Only one value is unit :()
(denoted by the same thing as the type). So actually the returned function will only take () to the given value. I think, the intention wasInt -> a -> Int
(for any a).Ie with your type this wouldn't type check:
(always 3) 5
only this would:(always 3) ()
This comment is hidden because it contains spoiler information about the solution
The test case implies that no arguments will be passed to this new function. Correct behavior of the returned function in the case of arguments passed should be explicitly mentioned in the instructions.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...