I was inspired to John Hughes’s talk “Why Functional Programming Matters” to try to re-implement his example of numerical analysis with an infinite sequence in Ruby. It’s not as clean as the Haskell version but it was interesting to implement.
I wonder if there’s a way to “shoehorn” lazy evaluation into Ruby while both simplifying the interface and honoring its existing idioms. I like Ruby for a lot of reasons, but modularity and functional programming isn’t one of them aren’t two of them.
I have half of another post drafted about all the problems I ran into when trying to implement this in Ruby. The tl;dr version is that internal and external iterator methods don’t play well together!
I wonder if there’s a way to “shoehorn” lazy evaluation into Ruby while both simplifying the interface and honoring its existing idioms. I like Ruby for a lot of reasons, but modularity and functional programming
isn’t one of themaren’t two of them.http://ruby-doc.org/core-2.4.1/Enumerator/Lazy.html
I have half of another post drafted about all the problems I ran into when trying to implement this in Ruby. The tl;dr version is that internal and external iterator methods don’t play well together!
I’ll admit when I saw “Exploring infinite sequences” I thought, aha, my favourite web site OEIS!
Sadly it wasn’t.
So for those geeks who haven’t met The On-Line Encyclopedia of Integer Sequences, here’s the link https://oeis.org/