Factorial in LISP
1
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)
2
Name:
Anonymous
2011-02-05 14:00
``in Lisp''.
3
Name:
Anonymous
2011-02-05 14:02
4
Name:
Anonymous
2011-02-05 14:07
(fun x) is superior to fun(x)
5
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))
6
Name:
Anonymous
2011-02-05 15:48
>>1
factorial n = procuct [1..n]
IHBT
7
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]
8
Name:
Anonymous
2011-02-05 15:53
>>7
Now post the implementation of the DSL.
>>5 is superior.
9
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.
10
Name:
Anonymous
2011-02-05 16:01
>>9
How about just putting it on pastebin?
11
Name:
Anonymous
2011-02-05 16:02
12
Name:
Anonymous
2011-02-05 16:03
>>10 >>11
First you put Haskell implementation there.
13
Name:
Anonymous
2011-02-05 16:04
>>10
>pastebin
Pasting Lisp code to this lowly PHP site would be a disgrace.
14
Name:
Anonymous
2011-02-05 16:07
15
Name:
Anonymous
2011-02-05 16:14
16
Name:
Anonymous
2011-02-05 16:16
>>15
But I'm
>>5 , I don't care about dead dogs.
17
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.
18
Name:
Anonymous
2011-02-05 16:20
: factorial 1 swap 1- for i * next ;
19
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.
20
Name:
Anonymous
2011-02-05 16:25
>>19
Fake account on gitdumb.
21
Name:
Anonymous
2011-02-05 16:27
>>20
git doesnt provide Common Lisp
22
Name:
Anonymous
2011-02-05 16:37
23
Name:
Anonymous
2011-02-05 16:38
In Lisp:
(((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))
24
Name:
Anonymous
2011-02-05 16:41
>>22
Not anonymous and they dont provide CL environment, only static pages.
25
Name:
Anonymous
2011-02-05 16:43
26
Name:
Anonymous
2011-02-05 16:44
>>24
Just fuck you and paste it somewhere.
27
Name:
Anonymous
2011-02-05 16:44
>>18
: factorial 1+ 1 tuck +do i * loop ;
Fixed.
28
Name:
Anonymous
2011-02-05 16:50
>>26
But I've nowhere to paste!
29
Name:
Anonymous
2011-02-05 16:50
30
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 ;
31
Name:
Anonymous
2011-02-05 16:52
>>30
//`'''````````,
o // ``in LISP'' `.,
,....OOo. .c;.',,,.'``.,,.```
.' ____.,'.//
/ _____ \___/.'
| / || \\---\|
|| || \\ ||
co co co co
32
Name:
Anonymous
2011-02-05 17:01
>>30
In Lisp:
{(x) (apply * (range 1 x))}
33
Name:
Anonymous
2011-02-05 17:24
34
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.
35
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.
36
Name:
Anonymous
2011-02-05 17:34
>>1
Haskell:
factorial = factorial'
factorial' isn't built in you say? Neither is your whoredsl.
37
Name:
Anonymous
2011-02-05 17:34
PERL 6: n! THREAD OVER.
38
Name:
Anonymous
2011-02-05 17:35
>>35
In C/C++ it would look like
xs[x]=1; xs[y]=2;
39
Name:
Anonymous
2011-02-05 17:36
>>36
Haskell isnt builtin either.
40
Name:
Anonymous
2011-02-05 17:36
Newer Posts