Skip to content

Instantly share code, notes, and snippets.

@hiroshi-maybe
Created March 23, 2013 10:09
Show Gist options
  • Select an option

  • Save hiroshi-maybe/5227189 to your computer and use it in GitHub Desktop.

Select an option

Save hiroshi-maybe/5227189 to your computer and use it in GitHub Desktop.
Generate infinite list of Newton-Raphson method
repApply :: (a->a)->a->[a]
repApply f x = x : repApply f (f x)
newton :: Int -> [Double]
newton n = repApply (\x -> (x+(fromIntegral n)/x)/2) 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment