Skip to content

Add concept tail-call-recursion #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 14, 2025
Merged

Add concept tail-call-recursion #751

merged 6 commits into from
Jun 14, 2025

Conversation

jiegillet
Copy link
Contributor

@jiegillet jiegillet commented May 16, 2025

Closes #692

I only added the concept so far, and now I'm questioning whether this should be part of #750, because any exercise requiring recursion would work out fine, maybe with an extra task "make it tail recursive".
Or maybe I'm just being lazy and I'll come up with an exercise idea later, let's see.

The beginning of the introduction was copied from the Elixir track.

Note: this article was very useful in creating this concept, and the elm-review rule it introduces will most likely be used in the analyzer.

@@ -0,0 +1,64 @@
# About
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great explanation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sitting on the shoulders of giants (@neenjaw)

@ceddlyburge
Copy link
Contributor

There is quite a lot of nuance to this, so maybe it is worth its own concept?

Base automatically changed from jie-recursion to main May 17, 2025 04:26
@jiegillet jiegillet force-pushed the jie-tail-recursion branch from 077421f to 210e710 Compare May 17, 2025 12:47

else
loop 0 [ 1 ]
loop 0 [ 1 ] []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tweaked this to make it tail recursive and add it to the list

@jiegillet jiegillet marked this pull request as ready for review May 17, 2025 12:50
@jiegillet
Copy link
Contributor Author

@ceddlyburge I found an exercise where recursion is needed, but it's very mathy. What do you think about it?

@jiegillet jiegillet mentioned this pull request May 19, 2025
@ceddlyburge
Copy link
Contributor

@ceddlyburge I found an exercise where recursion is needed, but it's very mathy. What do you think about it?

It looks like the bfs function is recursive in that exercise. Its 100 lines of code, which isn't that bad. Were you thinking about making it a practive exercise or a concept exercise? I think it does look a bit too complicated for a concept exercise, I think you would spend a lot more time thinking about the problem than about the concept ...

@ceddlyburge
Copy link
Contributor

Other thoughts from a quick google are binary search, towers of hanoi, search for a file in a folder structure

@jiegillet
Copy link
Contributor Author

jiegillet commented Jun 13, 2025

[sorry for the long break]

@ceddlyburge I found an exercise where recursion is needed, but it's very mathy. What do you think about it?

It looks like the bfs function is recursive in that exercise. Its 100 lines of code, which isn't that bad. Were you thinking about making it a practive exercise or a concept exercise? I think it does look a bit too complicated for a concept exercise, I think you would spend a lot more time thinking about the problem than about the concept ...

Which exercise are you referencing? pipers-pie doesn't use BFS and it's less than 50 lines of code.
It might be bit complicated, but I want to make sure we are talking about the same thing before I replace it.

@ceddlyburge
Copy link
Contributor

The bfs function is in the relative-distance exercise that andras recently added.

I think the recursion part of the relative-distance exercise is fairly minor, so I don't think it makes sense as a concept exercise (most of the problem is not about the concept). It would work as a practice exercise I think though.

Which exercise are you talking about?

@jiegillet
Copy link
Contributor Author

Which exercise are you talking about?

pipers-pie, the one I added to this PR :)

@ceddlyburge
Copy link
Contributor

That is quite a mathsy thing, but actually all the maths is simple. Its just some adding and multiplication really.

@jiegillet
Copy link
Contributor Author

Good! Then if you think the exercise is suitable, can I ask you to review the PR? :)

@jiegillet jiegillet requested a review from ceddlyburge June 13, 2025 13:07
@@ -929,17 +946,16 @@
"name": "Pascal's Triangle",
"uuid": "b7e456d7-e383-4e03-9126-c9b57c1287e1",
"practices": [
"lists"
"tail-call-recursion"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 practice exercises seems pretty good

@jiegillet jiegillet merged commit 7b66ed3 into main Jun 14, 2025
6 checks passed
@jiegillet jiegillet deleted the jie-tail-recursion branch June 14, 2025 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Concept: recursion
2 participants