Anonymous user
Horner's rule for polynomial evaluation: Difference between revisions
Horner's rule for polynomial evaluation (view source)
Revision as of 00:13, 6 May 2010
, 14 years ago→{{header|OCaml}}
(added ocaml) |
|||
Line 156:
<lang ocaml># let horner coeffs x =
List.fold_left (fun acc coef ->
val horner : int list -> int -> int = <fun>
Line 162:
horner coeffs 3 ;;
- : int = 128</lang>
It's also possible to do fold_right instead of reversing and doing fold_left; but fold_right is not tail-recursive.
=={{header|Oz}}==
|