Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Lisp and Scheme

Name: Anonymous 2007-03-08 8:14 ID:fc2iv5gF

Why is this shit still around? Didn't Haskell obsolete it 20 years ago?

Compare map:

 (define (map f lst)
   (let loop ((lst lst)
              (res '()))
     (if (null? lst)
       (reverse res)
       (loop (cdr lst)
             (cons (f (car lst)) res)))))

vs.

 map f []     = []
 map f (x:xs) = f x : map f xs

Name: Anonymous 2011-04-06 19:23

LISP:

(`+` 3 4 5 ?) 6


Haskell:

(3 `f` 4 `f` 5 `f`) 6


LISP:

len a b -> sqrt 0+@(map ?^2 b-a)

Haskell:

len (Point x1 y1) (Point x2 y2) = sqrt $ fromIntegral ((x2-x1)^2 + (y2-y1)^2)


LISP:

f [x _ @xs] -> x+xs,f

Haskell:

f = sum . map snd . filter (odd.fst) . zip [1..]



LISP:

clockwise[x@xs]->[@x@xs,transpose,rev,clockwise]

Haskell:

clockwise (x:xs) = x ++ (clockwise . reverse . transpose) xs
clockwise _ = []


LISP:

factorial 1->1; n->n*(factorial n-1)


Haskell

product :: [Integer] -> Integer
product []     = 1
product (x:xs) = x * product xs
factorial n = procuct [1..n]

-- alternatively:
factorial::Integer->Integer
factorial 0=1
factorial n=n*factorial(n-1)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List