4 kyu

Curry me softly

Description
Loading description...
Functional Programming
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    Also, where are the random tests?

    • JohanWiltink Avatar

      Dammit, I missed that. Two years and nobody flagged it. (I was worrying about other things, as mentioned below.)

      Care to write some?

    • Voile Avatar

      1AM here, so I don't think I'll be doing it right now.

      Idea: Do normal Array/String/RegExp/Date/etc stuff with random prototype functions using the curry function and randomized inputs.

  • Voile Avatar

    For fun, let's make sure this works with native global functions and methods too! (will involve some context)

    This part is very unclear and confusing as to how the kata expects you to handle the context.

    For the sake of other people's sanity: The kata expects you to handle the context by retrieving the context at the first time the initialized function is called. Everything after is not used.

    • JohanWiltink Avatar

      20 People managed, of which half voted they were Very satisfied. I was more worried it was called currying, but wasn't.

      I'll edit in your addition.

    • Voile Avatar

      Further question: Should we reset the context too after calling the wrapped original function without arguments?

    • JohanWiltink Avatar

      In reply to your original comment, not your last (we were posting simultaneously): Also mentioned in the very last comment, BTW. Description updated satisfactorily?

      Closing.

      Issue marked resolved by JohanWiltink 8 years ago
    • JohanWiltink Avatar

      Should we reset the context too after calling the wrapped original function without arguments?

      Leaving this for the original author to decide. He knows what he wants (supposedly).

      The whole context thing is a mess of course. I have no clue what he intended. (Taking the cowardly out here .. :P )

  • JohanWiltink Avatar

    I have approved this kata with a big caveat at the top that what is asked for is not currying, and I have wrapped uses of the term "currying" in quotes where it does not conform to the accepted definition.

    Maybe we can call the process described here, which, if not strictly currying, is interesting .. "currying softly" !? :yum:

    • sirRodge Avatar

      haha long time since I looked at this, thank you for feedback

      yes at the time I wrote this I was learning what currying was and was actually wrong as you said. I do still think it's interestng though :)

      will think about how to rephrase

  • kazk Avatar

    @sirRodge, I'm not an expert on functional programming either, but I think curry is misused and therefore causing confusions. Your kata is asking us to implement a function which returns a partially applicable function wrapping given function preserving the original execution context.

    It should allow multiple arguments to be passed into each invocation.

    This requirement contradicts with the definition of currying.

    In mathematics and computer science, currying is the technique of translating the evaluation of a function that takes multiple arguments (or a tuple of arguments) into evaluating a sequence of functions, each with a single argument. Currying is related to, but not the same as, partial application. Currying on Wikipedia

    • sirRodge Avatar

      Ah got it, yes i realize now that what im asking for is actually like an ES6 generator and that currying sticks with these pure functions like you've described, will fix

  • kirilloid Avatar

    Handling of this is described very vaguely. This kata still has the best description among all currying katas on codewars %-)

  • kirilloid Avatar

    The whole idea is pretty strange. Currying usually appears in context of pure function. At the same time conditions require us to have some hidden state. So the task of having such impure stateful currying is an oxymoron.

    • sirRodge Avatar

      Honestly I made this Kata to learn and am no expert on functional programming, is this not how currying kindof has to work in javascript (functions being first class citizens means multiple invocations necessarily produces intermediate functions)?

      I don't know another way it could but would like to see some sort of quick mock-up or if you could point me to an example of what you think is better.

    • sirRodge Avatar

      Oh I think I see, you would return a new function each time? So that the original function was not modified each time it is run?

      If so, I think this is better, I'm wondering if it works to change it since it would make everyone's answers wrong haha.

  • Abbe Avatar

    This comment has been hidden.