Ad
  • Custom User Avatar

    Being able to return a function from inside of another function is a basic feature of functional programming paradigm, and it's not meant to be useful in any particular scenario. It's more of a builing block which can be used as a part of solutions to other problems. It's like with objects in object oriented programming: objects are not meant to fulfill some scenario, but you can build solutions to many scenarios with objects, as well as you can solve them without objects.

    This specific kata might serve as an example of working with so called "generators", or "suppliers", or however it's called in terms of functional programming. But it's totally up to you how, why and if you use such supplier, or not.

  • Custom User Avatar

    Do you know in which kind of scenario something like this is useful?

  • Custom User Avatar

    I know right?
    What sense does this have in a real world scenario?

  • Custom User Avatar

    Oh ok now I understand :D

  • Custom User Avatar

    You probably misunderstood the task, so please read description again. You should not return the result of operation. When tests call f = function_factory(2,3,'+'), expected result is not f equal to 5. Your solution should return a function, which, when called, will return 5:

    f = function_factory(2,3,'+')
    result = f( ) #this is where tests fail because you returned 5 and not a function
    print(result) #result should be equal to 5
    

    I have not seen your code but I guess your solution makes f equal to 5, and test fail when they want to call f( ) because 5 is not callable.

  • Custom User Avatar

    Int not callable? i don't get it.

  • Custom User Avatar

    Little tip, use a dictionary so you don't have to check every argument.

  • Custom User Avatar

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