Writing Factorials in LISP
1
Name:
Anonymous
2010-10-21 19:24
Your damn unreadable one liners.
If you disagree without a doubt I then won't even partially trying to conceive of a better fixable situation the more time it takes.
2
Name:
Anonymous
2010-10-21 23:13
I don't think I could make sense of what you wrote no matter how many parens you add.
3
Name:
Anonymous
2010-10-22 1:37
Ah, Wernicke's aphasia. Very sad.
4
Name:
Anonymous
2010-10-22 4:57
>>3
Dr, how have you diagnosed Wernicke's so readily. Could it not be Broca's aphasia?
5
Name:
Anonymous
2010-10-22 10:07
(define (f x) (if (<= x 1) 1 (f (- x 1))))
6
Name:
Anonymous
2010-10-22 10:59
>>5
(define (f x) 1)
OMG OPTIMISED
7
Name:
Anonymous
2010-10-22 11:43
>>5
Now get rid of the global
by using a Y combinator. Go.
8
Name:
Anonymous
2010-10-22 11:43
>>4
0/10
Individuals with Broca's aphasia speak short, meaningful phrases that are produced with great effort. Affected people often omit small words such as "is", "and", and "the". For example, a person with Broca's aphasia may say the ambiguous phrase, "cup drink" which could have the intended meaning of a variety of phrases.
Individuals with Wernicke's aphasia speak in long sentences that have no meaning and add unnecessary words, much like
>>1- san.
9
Name:
Anonymous
2010-10-22 11:58
>>7 see
>>6
(1)
Do you really want that in lambda form?
10
Name:
Anonymous
2010-10-22 12:00
>>8
Expert wikipedia sourcer
11
Name:
Anonymous
2010-10-22 12:09
long fac(long n) { return n ? n * fac(n-1) : 1; }
12
Name:
Anonymous
2010-10-22 12:38
>>11
long
enjoy you're overflow
13
Name:
Anonymous
2010-10-22 12:48
14
Name:
Anonymous
2010-10-22 13:31
>>13
Why aren't you enjoying your overflowness?
15
Name:
Anonymous
2010-10-22 14:22
What is going on in this thread?
16
Name:
Anonymous
2010-10-22 14:53
We're overflowing.
17
Name:
Anonymous
2010-10-22 15:02
>>15
You forgot the "hai guise" prefix.
18
Name:
Anonymous
2010-10-22 17:04
I firmly believe that Abelson is by far a better educator than the Sussman. Abelson teaches things thoroughly, while Sussman just waltzes into class, writes some shit on the board, then waltzes the fuck out[1] .
[1] SICP lecture videos
19
Name:
Anonymous
2010-10-22 17:20
I guarantee that I am the only poster online at this very moment.
20
Name:
Anonymous
2010-10-22 18:03
>>19
Oh, don't worry about that. There's always lots of posers around.
21
Name:
Anonymous
2010-10-23 1:32
(define (factorial x) ; Calculate x!
(if (zero? x) 1 ; 0! = 1
(calc-fact x))) ; otherwise
(define (calc-fact x) ; x -> x(x-1)!
(* x (factorial (- x 1))))
(factorial 5)
Unreadable? One-liners?
22
Name:
Anonymous
2010-10-23 5:19
>>21
Why would you split a simple function like factorial into two functions?
23
Name:
Anonymous
2010-10-23 10:52
>>22
>>1 complaining about one-liners.
24
Name:
Anonymous
2010-10-23 11:58
>>23
Oh, right. If you really wanted to make it retard-friendly,
you should have written it in Java .
25
Name:
Anonymous
2010-10-23 13:57
(define (factorial n)
(loop ((for i (up-from 1 (to (+ n 1))))
(for x (multiplying i)))
=> x))
26
Name:
Anonymous
2010-10-23 16:23
(define (factorial n) (loop ((for i (up-from 1 (to (+ n 1)))) (for x (multiplying i))) => x))
27
Name:
Anonymous
2010-10-23 16:23
inb4 someone posts the Haskell one-liner for it
28
Name:
Anonymous
2010-12-24 22:17