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 14:00

``in Lisp''.

Name: Anonymous 2011-02-05 14:02

>>2
sorry :-(

Name: Anonymous 2011-02-05 14:07

(fun x) is superior to fun(x)

Name: Anonymous 2011-02-05 15:21

>>1
theres somethin rong w/ ur lambda caluclus but i ftfy :)

(λ(lambda)(((((((λ(lambda)(λ(λλ)(λ(λλλ)(λ(λambda)(λ(λαμβδα)(λ(λ)(if(λambda λαμβδα)λ((((((lambda lambda)λλ)λλλ)λambda)(λλλ λαμβδα))(λλ λαμβδα λ)))))))))(λ(lambda)(λ(λλ)(λ(λλλ)(λ(λambda)(λ(λαμβδα)(λ(λ)(if(λambda λαμβδα)λ((((((lambda lambda)λλ)λλλ)λambda)(λλλ λαμβδα))(λλ λαμβδα λ))))))))))(λ(lambda λαμβδα)(((((((λ(lambda)(λ(λλ)(λ(λλλ)(λ(λambda)(λ(λλλλ)(λ(λ)(if(λλ λλλλ)λ((((((lambda lambda)λλ)λλλ)λambda)(λλλ λλλλ))(λambda λ λαμβδα)))))))))(λ(lambda)(λ(λλ)(λ(λλλ)(λ(λambda)(λ(λλλλ)(λ(λ)(if(λλ λλλλ)λ((((((lambda lambda)λλ)λλλ)λambda)(λλλ λλλλ))(λambda λ λαμβδα))))))))))zero?)sub1)(λ(lambda λαμβδα)(((((((λ(lambda)(λ(λλ)(λ(λλλ)(λ(λambda)(λ(λλλλ)(λ(λ)(if(λλ λλλλ)λ((((((lambda lambda)λλ)λλλ)λambda)(λλλ λλλλ))(λambda λ)))))))))(λ(lambda)(λ(λλ)(λ(λλλ)(λ(λambda)(λ(λλλλ)(λ(λ)(if(λλ λλλλ)λ((((((lambda lambda)λλ)λλλ)λambda)(λλλ λλλλ))(λambda λ))))))))))zero?)sub1)add1)lambda)λαμβδα)))lambda)0)))sub1)zero?)lambda)1))

Name: Anonymous 2011-02-05 15:48

>>1
factorial n = procuct [1..n]

IHBT

Name: code less, create more 2011-02-05 15:52


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


versus:

product :: [Integer] -> Integer
product []     = 1
product (x:xs) = x * product xs
factorial n = procuct [1..n]

Name: Anonymous 2011-02-05 15:53

>>7
Now post the implementation of the DSL.

>>5 is superior.

Name: Anonymous 2011-02-05 15:59

>>8
Sorry, I dont know about any free Common Lisp hosting to provide you web access to it.

Name: Anonymous 2011-02-05 16:01

>>9
How about just putting it on pastebin?

Name: Anonymous 2011-02-05 16:02

Name: Anonymous 2011-02-05 16:03

>>10>>11
First you put Haskell implementation there.

Name: Anonymous 2011-02-05 16:04

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

Name: Anonymous 2011-02-05 16:07

Name: Anonymous 2011-02-05 16:14

Name: Anonymous 2011-02-05 16:16

>>15
But I'm >>5, I don't care about dead dogs.

Name: Anonymous 2011-02-05 16:18

>>9
Why do you need a hosting? Just zip/rar/7z up the source and upload it. If you want to update it, use github or similar.

Name: Anonymous 2011-02-05 16:20


: factorial 1 swap 1- for i * next ;

Name: Anonymous 2011-02-05 16:22

>>17
But I need a guestbook to store hate mails about how I butchered LISP and misunderstood concepts of Haskell. I also want to provide access for exectuing code directly from browser, so people I troll wont have to install SBCL beforehand or trust that my code wont mess their system.

Name: Anonymous 2011-02-05 16:25

>>19
Fake account on gitdumb.

Name: Anonymous 2011-02-05 16:27

>>20
git doesnt provide Common Lisp

Name: Anonymous 2011-02-05 16:37

Name: Anonymous 2011-02-05 16:38

In Lisp:
(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))

Name: Anonymous 2011-02-05 16:41

>>22
Not anonymous and they dont provide CL environment, only static pages.

Name: Anonymous 2011-02-05 16:43

>>23
In Lisp: >>5

Name: Anonymous 2011-02-05 16:44

>>24
Just fuck you and paste it somewhere.

Name: Anonymous 2011-02-05 16:44

>>18
: factorial 1+ 1 tuck +do i * loop ;

Fixed.

Name: Anonymous 2011-02-05 16:50

>>26
But I've nowhere to paste!

Name: Anonymous 2011-02-05 16:50

>>19
I chortled.

Name: code less, create more 2011-02-05 16:51

>>27
Lisp:

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

Forth:

: f 1+ 1 tuck +do i * loop ;

Name: Anonymous 2011-02-05 16:52

>>30

                       //`'''````````,
             o        // ``in LISP'' `.,
       ,....OOo.   .c;.',,,.'``.,,.```
    .'      ____.,'.//
   / _____  \___/.'
  | / ||  \\---\|
  ||  ||   \\  ||
  co  co    co co

Name: Anonymous 2011-02-05 17:01

>>30
In Lisp: {(x) (apply * (range 1 x))}

Name: Anonymous 2011-02-05 17:24

>>30
f 0=1; f=n*f(n-1)

Name: Anonymous 2011-02-05 17:30

>>33
I tried `=`, but it made code look a bit messy. That is why I decided to use `->` for maps and `//` for comments, because `--` just didnt stand on its own and `;;` is way better as a delimiter.

Name: Anonymous 2011-02-05 17:33

Though I still use `=` for sorted list construction and modification. For example:

[x=1 y=2 @xs]

adds to `xs` keys `x` and `y` with their respectively values.

Name: Anonymous 2011-02-05 17:34

>>1
Haskell:
factorial = factorial'
factorial' isn't built in you say? Neither is your whoredsl.

Name: Anonymous 2011-02-05 17:34

PERL 6: n! THREAD OVER.

Name: Anonymous 2011-02-05 17:35

>>35
In C/C++ it would look like

xs[x]=1; xs[y]=2;

Name: Anonymous 2011-02-05 17:36

>>36
Haskell isnt builtin either.

Name: Anonymous 2011-02-05 17:36

>>39
It had better be.

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