Junilu Lacar wrote:
Could the caveat with this solution be that it might give incorrect results if there is parallelism involved?
I'm having trouble wrapping my head around PYS' line 8-9, although I appreciate that he noted the non-functional nature of his cons and tail methods, which I was about to point out before I read the rest of his post.
Junilu Lacar wrote:@Mark - and Welcome to the Ranch!
This wouldn't be for school homework, would it? We try not to abet plagiarism here by providing outright solutions but since there already was one provided previously, I decided to post what worked for me. Hopefully this will give you some helpful ideas but at the same time I hope you don't pass these off as your own if it's for schoolwork.
Mark Bower wrote:Alas, I am a few decades past schoolwork!
Otto Zeimer wrote:one more solution with streams:
Stephan van Hulst wrote:Pierre's solution violates the reduce() contract because his accumulator is not stateless.
Piet Souris wrote:What does that mean in case of side effects?