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
Add the accumulate problem #25
Conversation
I think the general idea is to avoid built-in functions like You could implement (define/match (accumulate proc lst)
[(proc '()) '()]
[(proc `(,x . ,rst)) `(,(proc x) . ,(accumulate proc rst))]) or more traditionally like this: (define (accumulate proc lst)
(if (null? lst)
'()
(cons (proc (car lst))
(accumulate proc (cdr lst))))) |
empty) | ||
|
||
(test-equal? "doubling" | ||
(accumulate '(1 3 4) (lambda (arg) (arg * arg))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming you meant (* arg arg)
here.
application: not a procedure;
expected a procedure that can be applied to arguments
given: 1
arguments...:
#<procedure:*>
1
context...:
accumulate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or (arg . * . arg)
It would probably be helpful to have a couple more tests. You might find some inspiration in the LFE version. |
Sorry if my comments come off as terse or overly critical. That's not my intention. It's late here and I shouldn't be coding any more tonight... Thanks very much for getting involved! I hope my feedback is constructive rather than discouraging. |
Hi @yurrriq no worries, your comments are very constructive and I'll address them carefully later today (it was very early here and I missed silly stuff like |
Changed the body of two functions and added some tests.
Hi, anyone has any other comments? If the initial comments are addressed, I'd be happy to know how I can help to have it merged. |
Without running the code it looks good to me. @arguello, will you check it out and merge? |
looks good, thank you. |
🎉 |
Getting my feet wet. Any feedback would be appreciated :)