function in Haskell that can solve an equation -
i need write function in haskell can solve next problem(physic_problem): height (in whole number of meters) of shortest building drop ball such take @ to the lowest degree 5 seconds nail ground? equation can found here http://en.wikipedia.org/wiki/equations_for_a_falling_body
i tried hard on , need help!
thank much!
consider instance this,
g :: double g = 9.81 dist :: double -> double dist t = g * t^2 / 2
then,
> dist 5 122.625
additionally may want create module out of equations in wiki.
update
for delivering integral value consider example
dist' :: (integral a) => double -> dist' t = ceiling $ g * t^2 / 2
here utilize ceiling
(upper bound), yet note converting integral other rounding functions. hence,
> dist' 5 123
function haskell
No comments:
Post a Comment