List Info

Thread: "ocaml_beginners"::[] iterate in ocaml




"ocaml_beginners"::[] iterate in ocaml
country flaguser name
United States
2007-03-28 07:39:07

Is there a built-in o'caml equivalent of haskell's iterate function which applies a function to a number repeatedly as in f ( f ( .....(f x)..)
Thanks


---------------------------------
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] iterate in ocaml
country flaguser name
United Kingdom
2007-03-28 08:13:10

On Wed, Mar 28, 2007 at 05:39:07AM -0700, Logesh Pillay wrote:
> Is there a built-in o'caml equivalent of haskell's iterate function
> which applies a function to a number repeatedly as in f ( f ( .....(f
> x)..)

I don't think there's a built-in function, but it's very simple to
write one.

On the other hand, common forms of iteration are often captured more
elegantly by functions like List.map, List.fold_left and List.iter.

Rich.

--
Richard Jones
Red Hat

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )