English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] ANNOUNCE: mod_caml 1.0.6 - includes security patch
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-01-20 (12:31)
From: Eray Ozkural <exa@k...>
Subject: Re: [Caml-list] ANNOUNCE: mod_caml 1.0.6 - includes security patch
On Tuesday 20 January 2004 13:31, Markus Mottl wrote:
> "where" is one keyword, which I might find useful. Code can be made much
> more readable if function applications come first and values used in it
> are defined further below. Otherwise, the user may have to scan large
> portions of value definitions before getting to the "core" of a function.

Absolutely! It looks much better than 5 nested let scopes (although they are 
semantically identical). Where was this inefficient DFT function I had 
written. Ah, here  it is:
dft :: (RealFloat a) => (SampleVector (Complex a)) -> Int
    -> (SampleVector (Complex a))
dft x n =
    listArray (0, (n-1)) [transform f | f <- [0..(n-1)]]
    transform f = scale * (foldl1 (+) [freqcomp f k | k <- [0..(n-1)]])
    freqcomp f k = (x!k) * (exp_polar (-(2 * (fromIntegral k)
                                         * pi * (fromIntegral f) ) /
                                       (fromIntegral n)) )
    scale = 1/(fromIntegral n)

I find use of where keyword much more readable in many places.


Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr>
Comp. Sci. Dept., Bilkent University, Ankara  KDE Project: http://www.kde.org
www: http://www.cs.bilkent.edu.tr/~erayo  Malfunction: http://mp3.com/ariza
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners