4 ms·
Poe's law demonstrated.
by markrages 5y ago
Poe's law demonstrated.
- Chris_Newton 5y agoIndeed, though in a language designed for this style of programming, the idea behind that final example in the GP comment works fine. A Haskell version might look something like this: iterate (/2) 5.0 & takeWhile (>0.1) & map do_stuff The `iterate` generates the infinite sequence, the `takeWhile` specifies how much of it to use, and then we do stuff with each element. This is arguably a little nicer than the while loop since it exposes the real sequence of values you’re working with more explicitly, but at the very least it is comparably simple in its appearance. The Python version in the GP comment looks bad mostly because of the clumsy lambda syntax.