Sprachen fuer embedded-systems ...[WAS: CRONd - Speicher sparen]

Lutz Donnerhacke lutz at iks-jena.de
Die Apr 11 17:59:54 CEST 2006


Zum Spaß mal ein paar Haskell Beispiele mit Performance Angaben:

>let fac 0 = 1
>    fac 1 = 1
>    fac (x+1) = fac x + fac (x-1)
>in fac 10
89
(3204 reductions, 4999 cells)

> ...
> in fac 20
10946
(394056 reductions, 615558 cells, 2 garbage collections)

>let fac' 1 = (1,1)
>    fac' (x+1) = (b,a+b) where (a,b) = fac' x
>    fac = snd . fac'
>in fac 10
89
(345 reductions, 550 cells)

>...
>in fac 20
10946
(685 reductions, 1104 cells)

>let facs = 1:1:zipWith (+) facs (tail facs)
>    fac = (facs !!)
>in facs 10
89
(243 reductions, 346 cells)

>...
>in facs 20
10946
(456 reductions, 702 cells)