Ad
  • Custom User Avatar

    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

  • Custom User Avatar

    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?

  • Custom User Avatar