in reply to Re^3: Functional shuffle
in thread Functional shuffle

I think I'd gotten stuck in the mindset that functional programming requires streams, but there's no reason you couldn't use slices. Variables are not strictly functional, per se, but it's trivial to have an auxiliary function that does the same thing, so I don't object to them.

I see there's some confusion about what qualifies as functional. That's probably my fault for not specifying. I punted, because I don't think I had it well-defined in my own mind. But I think I have a better idea now:

In the purest sense, a functional program is one in which nothing is modified — all new values are modified copies of something else. In keeping with that, the only variables are parameters to the functions.

Most functional languages allow for some practical exceptions to avoid cumbersome jumping through hoops, as in the case of your temp variable. I like your solution a lot.


Caution: Contents may have been coded under pressure.