merits of Lisp vs Python

Paul Rubin http
Fri Dec 15 10:30:18 EST 2006


Wade Humeniuk <whumeniu+anti+spam at telus.net> writes:
> > "nif" is even cleaner in Haskell, if I have this right:
> >     nif x p z n | (x < 0) = n
> >                 | (x == 0) = z
> >                 | (x > 0)  = p
> > All Haskell evaluation is automatically lazy, so no lambdas
> > etc. needed.
> 
> You can use that style in CL.
> 
> (defun nif (x p z n)
>    (or (when (< x 0) n)
>        (when (= x 0) z)
>        (when (> x 0) p)))

Yeah but you can't apply it the same way.

   [nif x p z n | x <- [0,2.5,-8]]

evaluates exactly one of p, z, or n, for each of the args in that
list.  Side effects don't work the same way either, you have to use
special declarations around code with side effects.  I'm not yet
conversant enough with Haskell to know how to do it for this example
though.



More information about the Python-list mailing list