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

Factorial in LISP

Name: Anonymous 2011-02-05 13:59


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


compare to Haskell

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

Name: Anonymous 2011-02-05 17:39

>>40

$ ghc
bash: ghc: command not found

Name: Anonymous 2011-02-05 17:39

>>39
Neither are processor instructions.

Name: Anonymous 2011-02-05 17:40

>>41
Install House.

Name: Anonymous 2011-02-05 17:40

>>42
stop butthurting.
your language lost.
deal with it.

Name: Anonymous 2011-02-05 17:50

>>28
Excuses, excuses... if github doesn't work out for you, just archive it and put it on megaupload or some other file sharing site.

Name: Anonymous 2011-02-05 17:57

>megaupload
Pasting Lisp code to this lowly PHP site would be a disgrace.

Name: Anonymous 2011-02-05 18:01

>>44
your language lost.
Lisp never loses.

>>46
Pasting Lisp code to this lowly PHP site would be a disgrace.
paste.lisp.org

Name: Anonymous 2011-02-05 19:01

Name: Anonymous 2011-02-05 19:04

>>48
There's /prog/ for that.

Name: Anonymous 2011-02-05 19:07

>>49
/prog/ is too general

Name: Anonymous 2011-02-05 19:09

Name: Anonymous 2011-02-05 19:18

>>50
He obviously doesn't want to post his code since he's ashamed of it for some reason, so he'll give all kinds of excuses. If he wanted to publish his code for people to see, it would be incredibly easy and wouldn't take more than a few minutes to pack it up and upload anywhere.

Name: Anonymous 2011-02-05 19:26

>>52
Pasting Lisp code to this lowly PHP site would be a disgrace.

Name: Anonymous 2011-02-05 19:27

>>53
Pasting Lisp code to this lowly PHP site would be a disgrace.

Name: Anonymous 2011-02-05 19:31

>>54
doesnt stack

Name: Anonymous 2011-02-05 19:31

>>55
Pasting Lisp code to this lowly PHP site would be a disgrace.

Name: Anonymous 2011-02-05 19:34

Isn't the ``In Lisp'' DSL technically Lisp code? Isn't 4chan a lowly PHP site?

Name: Anonymous 2011-02-05 19:35

>>57
Shiichan is AN EXCEPTION.

Name: Anonymous 2011-02-05 19:50

>>58
Shiichan is also written in PHP, how is it an exception?

Name: Anonymous 2011-02-05 19:51

>>59
throw new Shiichan();

Name: Anonymous 2011-02-05 20:08

That exception will always go unhandled. Who would want to catch Shiichan?

Name: Anonymous 2011-02-05 20:23

>>61
That's why he shouldn't bitch about Shiichan, he doesn't handle it.

Name: Anonymous 2011-02-05 20:33

>>59
catch (Shiichan $_) {
   throw
new Up();
}

Name: Anonymous 2011-02-05 20:37

>>57
It was just little snippet. But if you host Lisp compiler on a PHP site, that would be a little strange as it would imply that your language is so useless, that it cant host even its own distribution. Of course this dont apply to Haskell, as Haskell is an ongoing research project, not a practical language, so its site is in PHP...

$ telnet haskell.org 80
Trying 78.46.100.180...
Connected to haskell.org.
Escape character is '^]'.
GET / HTTP/1.1
Host: haskell.org

HTTP/1.1 307 Temporary Redirect
Date: Tue, 21 Dec 2010 23:38:48 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch

Name: Anonymous 2011-02-05 20:37

>>63
throw jew Up();

Name: Anonymous 2011-02-05 20:41

0]=> telnet common-lisp.net 80
Trying 208.72.159.207...
Connected to common-lisp.net.
Escape character is '^]'.
GET / HTTP/1.1
Host: common-lisp.net

HTTP/1.1 200 OK
Date: Sun, 06 Feb 2011 01:52:06 GMT
Server: Apache/1.3.34 (Debian)
PHP/4.4.4-8+etch6 mod_fastcgi/2.4.2 mod_perl/1.29
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

Name: Anonymous 2011-02-05 20:42

>>65
Jewish wedding?

Name: Anonymous 2011-02-05 20:47

>>66
That is sad.

Name: Anonymous 2011-02-05 22:00

>>68
And expected.

Name: Anonymous 2011-02-05 23:03

>>68
what's so sad about it?
look like a normal LAMP server to me.

Name: Anonymous 2011-02-05 23:13

Non-toy language is non-toy. And learn2 HTTP.
[m]$ nc python.org 80
HEAD / HTTP/1.1
host: python.org

HTTP/1.1 200 OK
Date: Sun, 06 Feb 2011 04:06:44 GMT
Server: Apache/2.2.9 (Debian) DAV/2 SVN/1.5.1 mod_ssl/2.2.9 OpenSSL/0.9.8g mod_wsgi/2.5 [/code]Python/2.5.2
Last-Modified: Fri, 04 Feb 2011 10:18:37 GMT
ETag: "105800d-49a0-49b72348bd940"
Accept-Ranges: bytes
Content-Length: 18848
Content-Type: text/html

Name: Anonymous 2011-02-05 23:40

>>71
Non-shitty BBCoder doesn't fail BBCode.


0]=> telnet cliki.net 80
Trying 208.72.159.217...
Connected to cliki.net.
Escape character is '^]'.
GET / HTTP/1.1
Host: cliki.net

HTTP/1.1 302 Redirected
Date: Sun, 06 Feb 2011 04:45:33 GMT
Server: Araneida/0.84
Content-Type: text/html
Last-Modified: Sun, 06 Feb 2011 04:45:33 GMT
Location: http://www.cliki.net/index
Pragma: no-cache
Expires: Fri, 30 Oct 1998 14:19:41 GMT
Via: 1.1 cliki.net
Vary: Accept-Encoding
Transfer-Encoding: chunked

http://www.cliki.net/araneida


0]=> telnet racket-lang.org 80
Trying 129.10.115.116...
Connected to racket-lang.org.
Escape character is '^]'.
GET / HTTP/1.1
Host: racket-lang.org

HTTP/1.1 200 OK
Date: Sun, 06 Feb 2011 04:36:12 GMT
Server: Apache/2.2.15 (Fedora)
Last-Modified: Sat, 05 Feb 2011 09:10:12 GMT
ETag: "625b46-102f0-49b855db5e500"
Accept-Ranges: bytes
Content-Length: 66288
Connection: close
Content-Type: text/html; charset=UTF-8

(It's written in Racket)

Name: Anonymous 2011-02-06 0:13

Factorial in LISP
SLOW ASS FUCK

Name: Anonymous 2011-02-06 6:56

>>70
Maybe some hack to make some browsers work better, but real site is surelly in Lisp, just reports itself as PHP.

Name: Anonymous 2011-02-06 9:07

>>73
Chicken faster than C.

Name: Anonymous 2011-02-06 11:55

>>75
Only if you completely fail at C or intentionally write bad C code.

Name: Anonymous 2011-02-06 12:44

>>75
Why does chicken crossed the road?

Name: Anonymous 2011-02-06 12:46

>>77
Because it's AS FAST AS C

Name: Anonymous 2011-02-06 13:09

What about a memoizing factorial?

factorials = scanl (*) 1 [1..]
factorial n = factorials !! n

Name: Anonymous 2011-02-06 13:31

This is even garbage collector-friendly.
(define (memoize f)
  (let ((c (make-weak-hash)))
    (λ x
      (hash-ref c x(λ () (let ((y (apply f x))) (hash-set! c x y) y))))))
(define fib
  (memoize
   (λ (x)
     (if (< x 2) x
         (+ (fib (- x 1))
            (fib (- x 2)))))))

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