Comments (8)
Hello. Thanks for opening an issue on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed.
That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use this link to copy this into a new topic there.
Note: If this issue has been pre-approved, please link back to this issue on the forum thread and a maintainer or staff member will reopen it.
from clojure.
Reopening this as per: https://forum.exercism.org/t/new-concept-deriving-new-functions-from-existing-functions-partial-comp-memoize/7746
from clojure.
@bobbicodes, I just created a PR from my fork, but I don't see it in the list of PRs in the main branch. This is the first time I do a PR from a fork and I'm not sure if I did it correctly? I also tried to select the reviewer but couldn't unfortunately...
The PR includes only the new concept, not the exercises, at this point in time... should I wait until I include exercises and create a new PR?
from clojure.
We could merge the concept now to get that out of the way... I reopened the PR so I'll comment over there.
from clojure.
Hi @bobbicodes, I was just thinking about possible exercises, and I have some that might be appropriate. However, I realize that basically anything that one can do with partial
, can be done with an anonymous function, at least for solving those exercises. A similar thing happens with comp
, where one can use a direct composition of functions rather than using this construct, and also with juxtp
. They all seem to add syntactic sugar and be a convenience that one can opt to not use (there might be situations where they are strictly required but I can't think of them).
My question is: to what extent is this important? Is there a way to enforce the use of those specific functions when testing an exercise, e.g, through the analyzers / representers that are discussed by the Exercism team?
from clojure.
@bobbicodes In order to be specific, I include here a very rough description of the exercises.
We have Mary and John, who do frequent trips by bike:
- They want to calculate their average speed based on their recent trips, where the input is the distance from one destination to the next and how long it took to reach that destination.
- Based on their average speed, they want to estimate how long it will take to perform their next planned trips. The input for each trip is a list of distances between destinations. For example, one of the next planned trips is from Paris to Lyon, then from Lyon to Milan, then from Milan to Rome: they have the distances between each pair of cities, and they can build a list of distances based on that, something like
'(800, 500, 300)
- Use
partial
to make this calculation any time they want to plan a new trip. - Use
comp
to update their average speed and then apply the updated speed to estimate the total time it will take to do a new trip they have in mind. - Use
juxtp
to evaluate different trips that they are considering, in terms of how long it would take each of one. The input would be a list of distances for each trip, and the output the total time required.
The idea is that comp
is typically used (AFAIK) with a single input from the second function onwards, so that we need to use partial
(or an anonymous function) as part of comp
. I think a similar thing happens with juxtp
, but I'm not sure about that.
While estimating the total times for each potential trip, they may want to play a bit with the trips, and add, modify, or remove destinations several times. Sometimes they might end up with the original trip, and they don't want to have to annotate the previously computed distances. Let's imagine that calculating the time it takes to go from one destination to another one is computationally expensive. We can use memoize to compute those times, so we save computational cost when requiring those results again. Then we can have a function that, given a potentially long list of cities, calculates the total estimated time for that trip. They would be evaluating many potential lists (one for each trip, where they have many possible trips in mind, and for each trip they would be playing with many possibilities, i.e., changing the list of cities many times and calculating their total time). We can also use memoize, not only for the pairwise times, but for the total time, in case the list is repeated while exploring the possibilities.
A final task might be a group of people that bet on which couple will be making the same trip faster, based on the average speed of each couple. Here we could use map
and partial
, where map
takes a list of partial functions, one for each couple, and the total distance of the trip. Again, anonymous functions could be used here instead of partial ones...
Please let me know your thoughts! Thank you very much for your help.
from clojure.
...I realize that basically anything that one can do with partial, can be done with an anonymous function, at least for solving those exercises. A similar thing happens with
comp
...
It's funny that you say this because I actually never use comp
or partial
in my own code, and whenever I see them I compulsively have to change them to anonymous functions because they make so much more sense to me! I've heard others say similarly, so I've never been motivated to use them. The one exception I've seen is when using comp
with transducers, but that's obviously out of scope for this exercise.
juxt
is different, though, there are some very useful patterns with it... years ago I even did a recurring blog series called just-juxt where every day I posted a new solution using juxt
, but theh Tl;DR is it comes in handy any time you want to generate a sequence of pairs.
So far we haven't enforced the usage of the concepts so it's been on the student to get the intended lesson out of the exercise. For example, in the exercise teaching the Java Character
class, I've seen students solve it using regex. This could be addressed with an exercise-specific analyzer, but for now I wouldn't worry about it.
from clojure.
Thanks @bobbicodes. In that case, I will go ahead and start working on these exercises, if you think the description of them that I sent to you makes sense! Thanks again for your feedback.
from clojure.
Related Issues (20)
- User is not told what the error is when a runtime error occurs HOT 1
- Rotational Cipher Tests differ from description HOT 2
- Broken URL in strings concept
- Elyses Destructured Enchantments: Tests mix up Expected and Actual results HOT 1
- Complex Numbers: Tests mix up Expected and Actual results, and unclear about requiring floats rather than rationals HOT 1
- Implement new learning exercise: Protocols
- Bank Account problem under wrong concept? HOT 2
- Implement new learning exercise: Atoms HOT 1
- Tracks on Tracks on Tracks: Incorrect implementation of task 4 passes test for task 4, but fails test for task 6 HOT 3
- Difficult to reproduce tests locally HOT 2
- test HOT 1
- Building a training set of tags for clojure HOT 21
- The specification of 'memoize-transform' in the coordinate-transformation exercise can be made more precise HOT 1
- Leap 48in24 approaches HOT 1
- Reverse-string 48in24 approaches HOT 3
- Exercises to port HOT 4
- Approaches for raindrops HOT 1
- Error in test for Card Games exercise, 6. More averaging techniques HOT 1
- No function found on command line or in :exec-fn during test execution HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clojure.