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

I'm learning Haskell.

Name: Anonymous 2011-10-08 7:33


Lisp              | Haskell
------------------|------------------
map f l           | map f l
map list l1 l2    | zip l1 l2
map list l1 l2 l3 | zip3 l1 l2 l3
map f l1 l2       | zipWith f l1 l2
map f l1 l2 l3    | zipWith3 f l1 l2 l3



Lisp                        | Haskell
----------------------------|---------------------------------------------------
* (floor (/ 1 0))           | Prelude> floor (1/0)
DIVISION-BY-ZERO signalled  | 1797693134862315907729305190789024733617976978942306572
                            | 7343008115773267580550096313270847732240753602112011387
                            | 9871393357658789768814416622492847430639474124377767893
                            | 4248654852763022196012460941194530829520850057688381506
                            | 8234246288147391311054082723716335051068458629823994724
                            | 5938479716304835356329624224137216



Lisp                             | Haskell
---------------------------------|---------------------------------------------------
* (expt -1 (+ 2 1.0e-15 -1e-15)) | Prelude> (-1)**(2 + 1e-15 - 1e-15) :: Double
1.0                              | NaN



Lisp                     | Haskell
-------------------------|-------------------------
* (expt -1 (exp 1))      | Prelude> (-1) ** exp 1
#C(-0.6332554 0.7739428) | NaN



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



Lisp                        | Haskell
----------------------------|---------------------------------------------------
$ sbcl                      | $ ghci
* +3                        | Prelude> +3
3                           | <interactive>:1:0: parse error on input `+'
*                           | Prelude>



Lisp                        | Haskell
----------------------------|---------------------------------------------------
reduce                      | fold, foldl, foldr, foldl',
                            | foldr1, foldl1, foldl1
                            |
elt                         | fst snd thd fth ffth...




Lisp                                  | Haskell
--------------------------------------|-----------------------------------------
(EVAL (SETQ X '`(EVAL (SETQ X ',X)))) | <interactive>:1:0: Not in scope: `eval'



Lisp                    | Haskell
------------------------|-------------------------------------------------------
* (type-of 123)         | <interactive>:1:0: Not in scope: `typeof'
(INTEGER 0 536870911)   |



Lisp                      | Haskell
--------------------------|-----------------------------------------------------
(map #'map (read) (read)) | Couldn't match expected type `[t1] -> t'
                          |        against inferred type `[[a] -> [b]]'



Lisp                       | Haskell
---------------------------|----------------------------------------------------
Prefix notation.           | Prelude> let fac 1 = 1; fac n = n * fac n-1
                           | Prelude> fac 4
                           | *** Exception: stack overflow
                           |
                           | Prelude> let f 1 = 1; f n = ((*)(n)((f) ((-) n 1)))
                           | Prelude> ((f) 4)
                           | 24




Lisp                     | Haskell
-------------------------|------------------------------------------------------
* (setf Tree             | data Tree a = Empty | Node (Tree a) a (Tree a)
        '((n 5 (n 5 n))  | tree = Node
          4              |       (Node Empty 5 (Node Empty 5 Empty))
         ((n 5 n) 6 n))) |        4
                         |       (Node (Node Empty 5 Empty) 6 Empty)



Lisp                       | Haskell
---------------------------|---------------------------------------------------
Speed comparable to C/C++  | The fastest BWT implementation written in Haskell,
                           | after weeks of optimization by several experts,
                           | remained over 200x slower than C++.





Lisp                      | Haskell
--------------------------|-----------------------------------------------------
* (defun yoba (a b)       | Prelude> :{
    (if (< a b)           | Prelude| let yoba a b = if a < b
        '(123 "abc")      | Prelude|                then [123, "abc"]
        '("abc" 123)))    | Prelude|                else ["abc", 123]
* (* 2 (car (yoba 1 2)))  | Prelude> :}
245                       | <interactive>:1:30:
*                         |     No instance for (Num [Char])
                          |       arising from ...

Name: Anonymous 2011-12-27 22:20

This is SBCL 1.0.54, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>;.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (expt -1 (+ 2 1.0e-15 -1e-15))

1.0
* (+ 2 1.0e-15)

2.0
*


yeah... no

Name: Anonymous 2011-12-27 22:29

Lisp                     | Haskell
-------------------------|-------------------------
* (expt -1 (exp 1))      | Prelude> (-1) ** exp 1
#C(-0.6332554 0.7739428) | NaN

i think here in fact haskell does the right thing.

in lisp you jump to the complex number vagon, where you instead wanted a Floating number. if i wanted a complex number in haskell i would had

import Data.Complex

Prelude Data.Complex> ((-1) :+ 0)** (exp 1)
(-0.6332556513148192) :+ 0.773942685266709

i think lisp should get it right, it's not cool if you jump from one field to another (mathematicaly speaking)

Name: Anonymous 2011-12-27 22:37

Lisp                       | Haskell
---------------------------|---------------------------------------------------
Speed comparable to C/C++  | The fastest BWT implementation written in Haskell,
                           | after weeks of optimization by several experts,
                           | remained over 200x slower than C++.


Source?

Lisp                    | Haskell
------------------------|-------------------------------------------------------
* (type-of 123)         | <interactive>:1:0: Not in scope: `typeof'
(INTEGER 0 536870911)   |

uhh was "import Data.Typeable" too much for you?

Prelude Data.Typeable> typeOf 2.6963
Double
Prelude Data.Typeable> typeOf "mom i love you"
[Char]

Lisp                       | Haskell
---------------------------|----------------------------------------------------
Prefix notation.           | Prelude> let fac 1 = 1; fac n = n * fac n-1
                           | Prelude> fac 4
                           | *** Exception: stack overflow
                           |
                           | Prelude> let f 1 = 1; f n = ((*)(n)((f) ((-) n 1)))
                           | Prelude> ((f) 4)
                           | 24


this one is stupid, you defined fac 2 diferent times.
Prelude Data.Typeable> let {fac 1 = 1; fac n = n * fac (n-1)}
Prelude Data.Typeable> fac 4
24

Lisp                                  | Haskell
--------------------------------------|-----------------------------------------
(EVAL (SETQ X '`(EVAL (SETQ X ',X)))) | <interactive>:1:0: Not in scope: `eval'

haskell doesn't need eval.

why am i posting on a troll thread?

Name: Anonymous 2011-12-27 22:47

>>43

you are providing hope for those of us that don't yet know haskel.

Name: Anonymous 2011-12-27 22:48

>>41
>your number by default is rounded upon presentation
>be surprised when it appears round
hurr haskellfags

Name: Anonymous 2011-12-27 23:06

>yoba
Yet another russian faggot.

Name: Anonymous 2011-12-27 23:28

>>45
why should that be? not a haskellfag but it seem rather strange.

(+ 2 1.0e-15) != 2

why round the result to appear as a Int when it obviously was a floating point operation?

or is for some cause i don't know?

Name: Anonymous 2011-12-28 1:41


Lisp               | Haskell
-------------------|------------------------
(lambda (x) (x x)) | Prelude> \x -> x x
                   |     Occurs check: cannot construct the infinite type

Name: sageru 2011-12-28 1:42

>>47
I was just trolling, but I assume it's because you're actually looking at the number at a human interface. If you passed the value of the operation to a function and then outputted the value to a file or read it using a custom reply command, I'm guessing it would show the actual value. My reasoning would be if you tried to see the actual value anyways, it would either like like a ridiculously long value, or it would give the mantissa and multiplicand or whatever the names are.

Name: Anonymous 2011-12-28 1:47

>>48
    Lisp               | Haskell
    -------------------|------------------------
    (lambda (x) (x x)) | Prelude> \x -> x x
                       |     Occurs check: cannot construct the infinite type

uhh

fix :: (a -> a) -> a
fix f = let x = f x in x

i am not even a real haskeller

Name: Anonymous 2011-12-28 2:05

>>50
crap :: (crap -> crap) -> crap
looks like crap.
is that because it aint Lisp?

Name: Anonymous 2011-12-28 2:19

>>51
it can be what ever you want, it will typecheck anyways

Name: Anonymous 2011-12-28 3:30

yoba
вот ты и спалился, петушок

Name: Anonymous 2011-12-28 3:51

>>51
Lisp is shit, but Haskell is THE worst faggot shit.

Name: Anonymous 2011-12-28 5:42

>>50

yeah, the type expression for a function that returns itself is infinitely long. You run into the same problem in C if you want to declare a function that returns a pointer to itself. You ahve to cast it as void* and then recast the return value to void*(*)(...)

Name: Anonymous 2011-12-28 6:37

>void*(*)(...)
C is easy and simple..they said.

Name: Anonymous 2012-04-15 1:49

bump

Name: Anonymous 2012-04-15 2:05

>>57
SO FUCKING FUCK YOU FAGGOT FOR NECROBUMPING

YES I AM MAD

Name: >>55 2012-04-15 2:30

>>56
example:

scheme:


((lambda (x) (x x)) (lambda (x) (x x))


although let's write using named functions to make the translation easier:


(define (u f) (f f)) ;; take a function and call it with itself as the argument.
(u u) ;; infinite loop


c


#include <stdio.h>

void* u(void* f) {
  printf("called u\n"); // It'll print this a lot before it segfaults from a stack explosion.
  return ((void*(*)(void*))f)(f);
}

void main() {
  u(u);
}


You could also write it like this:

#include <stdio.h>

void* u(void*(*f)(void*)) {
  printf("called u\n");
  return f(f);
}

void main() {
  u((void*(*)(void*))u);
}

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