Multiple applications of a function
Marcin 'Qrczak' Kowalczyk
qrczak@knm.org.pl
16 Sep 2001 15:11:27 GMT
Sun, 16 Sep 2001 10:52:07 -0400 (EDT), Mark Carroll <mark@chaos.x-philes.com> pisze:
> To multiply apply a function, I'm currently using:
>
> multiplyApply f n a = (iterate f a) !! n
>
> ...is there a Prelude function I've missed that already does this?
Unfortunately not.
> Could I be doing this better?
I think an explicit recursion would make it easier to compile
efficiently, and it can give a better error message for n < 0.
--
__("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK