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.
Calculating with Funtions with parenthesis
... but those are commas instead
https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39
similar to the link but with using a comma as a parenthesis...
let me explain:
five(times(one()),plus(one())) == 6 // (5 * 1) + 1
five(times(one(plus(one())))) == 10 // 5 * (1 + 1)
five(times(one(plus(one(times(two())))))) == 15 // 5 * (1 + (1 * 2))
five(times(one(),(plus(one(times(two())))))) == 7 // (5 * 1) + (1 * 2)
five(times(one(),(plus(one(),(times(two())))))) == 12 // ((5 * 1) + 1) * 2
What if we have operation precedence with comma?
I tried to figure how this could works:
Test.assert_equals(five(times(one(plus(one())))), 10)
Test.assert_equals(five(lambda x: x * 1, lambda x: x + 1), 6)
Test.assert_equals(five(times(one(), plus(one()))), 6)
Do you have an idea?
Why this works D: ?