Example code for a blog post
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
numerical_analysis.hs
numerical_analysis.rb

README.md

Lazy Numerical Analysis

This takes Haskell code by John Hughes and translates it to Ruby to play around with using infinite sequences in an eagerly evaluated language. It is the companion code for a blog post on using infinite sequences in Haskell and Ruby.

Running the code

For Ruby, you need Ruby 2.0 or greater:

$ irb
require_relative 'numerical_analysis'
sqrt 1000
# => 31.622776601684336

I used Stack to install Haskell. Then you can run:

$ stack ghci
:load numerical_analysis.hs
*Main> sqrt 1000
31.622776601684336
*Main> deriv (**2) 5
10.00006103515625

Futher reading