Skip to content

Instantly share code, notes, and snippets.

@jdar
Created May 24, 2010 04:08
Show Gist options
  • Save jdar/411514 to your computer and use it in GitHub Desktop.
Save jdar/411514 to your computer and use it in GitHub Desktop.
def coefs_to_parabola(*coefs)
proc, order = coefs.inject([lambda{|x|x},0]) do |(proc,order),coef|
[
Proc.new {|x| coef * x**order + proc.call(x) },
order += 1
]
end
proc
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment