New concept: deriving new functions from existing functions (partial, comp, memoize)

Would there be interest in creating a concept dedicated to function tools such as comp, partial, memoize, that facilitate deriving new functions from existing ones? If that’s the case, I would volunteer on writting the concept and at least one exercise for it.

(+cc @porkostomus)

I think that would be a lovely addition to the syllabus. juxt happens to be one of my favorite functions. I just haven’t gotten that far yet because we are still missing much more fundamental concepts like hash-maps, and higher-order functions like map, filter and reduce. But having an exercise teaching these function-generating functions would certainly be a huge benefit regardless, so if you would like to contribute it I will gladly help get it merged.

Writing an exercise is very tricky, however, and there have been several written before that haven’t made it for various reasons. It needs to be just the right scope that can be captured by unit tests, without being too difficult and without doing things like asking the student to wrap functions that already exist.

(This is actually why we don’t have an exercise for hash-maps, because I haven’t found a way to do it that I’m satisfied with)

This is not meant to be discouraging, but it’s important to understand that it’s a lot of work that is not always guaranteed to succeed.

To get an idea what hasn’t worked, you could take a look at the deprecated lists exercise: https://github.com/exercism/clojure/tree/main/exercises/concept/tracks-on-tracks-on-tracks

This exercise failed in both directions - the first few tasks were too easy, involving just shadowing core functions, and the final task could not be easily solved using the concepts that the student could reasonably be expected to know at that point (i.e. the ergonomic solution required threading macros).

That’s awesome. Thank you very much for your help. In that case, I will give it a try and put you as reviewer if that’s fine with you. Thanks again!

@IsaacG Link to the PR: Concepts/functions generating functions by JaumeAmoresDS · Pull Request #589 · exercism/clojure · GitHub

1 Like