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

The joke that is Haskell stdlib

Name: TRUE TRUTH EXPERT 2010-05-17 5:19

oBSERVE MY GOOD OL' FELLAS, THE JOKE THAT IS 'HASKELL STDLIB'. i DO NOT DOUBT THE EXCELLENCE IN HASKELL THEORY, BUT ALLOW ME TO MAKE FUN OF THE FRIVOLOUS LIBRARY THEY HAVE FOR STANDARD. LA-FUCKING-OWL.


-- | 'zip' takes two lists and returns a list of corresponding pairs.
-- If one input list is short, excess elements of the longer list are
-- discarded.
zip :: [a] -> [b] -> [(a,b)]
zip (a:as) (b:bs) = (a,b) : zip as bs
zip _      _      = []

;; I shall compare it with Communist Lisp
;; notice the solution is more general
;; and the documentation is built-in
(defun zip (&rest lists)
  "zip takes lists and returns corresponding pairs"
  (apply #'mapcar #'list lists))


o GUESS WAT! BAAA!!! hASKELL PROVIDES zip3 HOHOHOH. wAT ABOUT ZIP4 YOU ASSHOLES??

wAIT, WAIT. nOW IT GETS BETTER.


-- | 'unzip' transforms a list of pairs into a list of first components
-- and a list of second components.
unzip    :: [(a,b)] -> ([a],[b])
{-# INLINE unzip #-}
unzip    =  foldr (\(a,b) ~(as,bs) -> (a:as,b:bs)) ([],[])


;; La Communa lispa
(defun unzip (&rest lists)
  "list of pairs -> list of components"
  (apply #'zip lists))

oH SHIT!!!! fULL GENERAL SOLUTION WITH THE POWAH OF LISPA, HA SS KELL STDLIB IS A JOKE. dID YOU FUCKING LOL READING THIS POST?

Name: Anonymous 2010-05-17 8:19

>>19
$ ghci
GHCi, version 6.10.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> import Data.List
Prelude Data.List> transpose [[1,2,3],"abc"]

<interactive>:1:16:
    No instance for (Num Char)
      arising from the literal `3' at <interactive>:1:16
    Possible fix: add an instance declaration for (Num Char)
    In the expression: 3
    In the expression: [1, 2, 3]
    In the first argument of `transpose', namely `[[1, 2, 3], "abc"]'
Prelude Data.List> :t transpose
transpose :: [[a]] -> [[a]]

Name: Anonymous 2010-05-17 8:29

>>20
Prelude Data.List Data.Char> transpose [[1,2,3], map ord "abc"]
[[1,97],[2,98],[3,99]]
Prelude Data.List Data.Char> transpose [map chr [1,2,3], "abc"]
["\SOHa","\STXb","\ETXc"]
Prelude Data.List Data.Char>


but why the fuck would you want to do that?

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