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

Fucking Haskell and zips

Name: Anonymous 2011-04-23 14:08

So,

Haskell                          | Lisp
zip      l1 l2                   | (map list l1 l2)
zip3     l1 l2 l3                | (map list l1 l2 l3)
zip4     l1 l2 l3 l4             | (map list l1 l2 l3 l4)
zip5     l1 l2 l3 l4 l5          | (map list l1 l2 l3 l4 l5)
zip6     l1 l2 l3 l4 l5 l6       | (map list l1 l2 l3 l4 l5 l6)
zip7     l1 l2 l3 l4 l5 l6 l7    | (map list l1 l2 l3 l4 l5 l6 l7)
N/A                              | (map list . ls)
map      f  l                    | (map f l)
zipWith  f  l1 l2                | (map f l1 l2)
zipWith3 f  l1 l2 l3             | (map f l1 l2 l3)
zipWith4 f  l1 l2 l3 l4          | (map f l1 l2 l3 l4)
zipWith5 f  l1 l2 l3 l4 l5       | (map f l1 l2 l3 l4 l5)
zipWith6 f  l1 l2 l3 l4 l5 l6    | (map f l1 l2 l3 l4 l5 l6)
zipWith7 f  l1 l2 l3 l4 l5 l6 l7 | (map f l1 l2 l3 l4 l5 l7)
N/A                              | (map f . ls)


All this shit to achieve what Lisp does with ONE function? That is 6 lines of actual code in a naive implementation? Seriously?

(define map
 (case-lambda
  ((f xs)
   (do ((xs xs (cdr xs))
        (r '() (cons (f (car xs)) r)))
     ((null? xs) (reverse r))))
  ((f . xss)
   (do ((xss xss (map cdr xss))
        (r '() (cons (apply f (map car xss)) r)))
     ((ormap null? xs) (reverse r))))))

Name: Anonymous 2011-04-23 15:13

>>4
Actually, you can. It's Haskell's type system that can't express Lisp's map. That, and the curried functions (no, ``curried function'' doesnt mean (+ 3), it's unary functions that return unary functions). Both have advantages and disadvantages. I'm not your usual language troll, I know what I say.

Yet, the map|zip(With)?[1-7]? hell can lead to code duplication and it's really awful to see.

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