Closed TheLoneWolfling closed 8 years ago
OK let me try my best at these:
Thank you!
Running through:
- I don't think functions make sense for acc curr.
I fully agree. But I know some people would disagree with me, hence the question.
one let_map
It's actually worse than that... Think of what currently happens with variables in nested functions, for instance...
3/4/5
OK. I'm a programmer right out of university who is currently looking for work, including in QA, if that answers your question.
reduce (empty array) -> empty array?
This will mess up many things - suddenly your return type changes! (I would prefer if it was "error if no initializer value, else initializer value".)
operating on strings as well as arrays
There's a pretty easy generic method to do this, once we start encapsulation.
Hey look, you were right! At least in JS, and I'm guessing other languages, the behavior is to return the initializer or throw an error if there is none. Good call. We can emulate that behavior.
Sounds good.
A couple of related questions about how reduce should work, in your mind.
Currently the syntax is essentially
(reduce array_or_func_returning_array acc_var cur_var func [optional_init_val])
. 4 or 5 arguments.(reduce [2,1] a a (/ a a))
)