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: >>16 2011-10-08 12:05

Also, I'm guessing >>1 is Symta/``in Lisp''-guy or someone who read his examples.
I've been thinking lately about the implementation of an abstract machine over Peano Arithmetic which is similar to lambda calculus/universal turing machine in that it has infinite memory (actually, that's wrong, it has unbounded memory, but it's representable as always a finite integer, no matter how large) and it got me thinking about a good way of encoding integers(bignums) as I need to be able to encapsulate/store them within more regular memory (also integers). My current naive encoding is this:
encoding of n = 1...repeated log2_n times...1,0,n(taking 2^(log2_n) bits).
It seems a bit inefficient and I wonder if I should instead use recursive applications of log2_n instead to encode the length.
The other option would be to use a terminator symbol that specifies when a number is complete.
To my minor, but expected annoyance I found out that SBCL and SML's bignum's are actually using a fixed size field for representing the size (which depends on what architecture you run it - it's just derived from the CPU's register/max memory size, which makes perfect sense when you're dealing with a finite physical RAM/register machine, but might not make as much sense if you could serialize your results on disk or if you were working on an abstract machine model divorced from this particular physical reality).

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