-
Notifications
You must be signed in to change notification settings - Fork 193
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
[CH4] A more concise implementation of fibTailRec. #452
Comments
I like it! I think we should still keep the existing verbose and beginner-friendly reference solution, but you're welcome to make a PR to add your more optimized solution too. Just add it after the reference solution here: purescript-book/exercises/chapter4/test/no-peeking/Solutions.purs Lines 76 to 86 in 427f698
Could call it fibTailRec2 . Might be good to also include a comment describing that this is another way to do it by "counting down".
And be sure to test it: purescript-book/exercises/chapter4/test/Main.purs Lines 147 to 156 in 427f698
You could make a helper within that suite which calls both versions, and then replace the calls to each test case with a call to the helper. Similar to what's done for purescript-book/exercises/chapter4/test/Main.purs Lines 126 to 134 in 427f698
Note that you'll also need to make sure that the test for your optimized reference solution is deleted when users call purescript-book/scripts/prepareExercises.sh Lines 19 to 20 in 427f698
Might be good to increase coverage too for inputs |
Hi,
What do you think of the following implementation of
fibTailRec
from CH4?The text was updated successfully, but these errors were encountered: