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

Pages: 1-

Writing Factorials in LISP

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.

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.

Name: Anonymous 2010-10-22 1:37

Ah, Wernicke's aphasia. Very sad.

Name: Anonymous 2010-10-22 4:57

>>3
Dr, how have you diagnosed Wernicke's so readily. Could it not be Broca's aphasia?

Name: Anonymous 2010-10-22 10:07

(define (f x) (if (<= x 1) 1 (f (- x 1))))

Name: Anonymous 2010-10-22 10:59

>>5
(define (f x) 1)
OMG OPTIMISED

Name: Anonymous 2010-10-22 11:43

>>5
Now get rid of the global by using a Y combinator. Go.

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.

Name: Anonymous 2010-10-22 11:58

>>7 see >>6
(1)

Do you really want that in lambda form?

Name: Anonymous 2010-10-22 12:00

>>8
Expert wikipedia sourcer

Name: Anonymous 2010-10-22 12:09

long fac(long n) { return n ? n * fac(n-1) : 1; }

Name: Anonymous 2010-10-22 12:38

>>11
long
enjoy you're overflow

Name: Anonymous 2010-10-22 12:48

>>12
I'm overflow? damn.

Name: Anonymous 2010-10-22 13:31

>>13
Why aren't you enjoying your overflowness?

Name: Anonymous 2010-10-22 14:22

What is going on in this thread?

Name: Anonymous 2010-10-22 14:53

We're overflowing.

Name: Anonymous 2010-10-22 15:02

>>15
You forgot the "hai guise" prefix.

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

Name: Anonymous 2010-10-22 17:20

I guarantee that I am the only poster online at this very moment.

Name: Anonymous 2010-10-22 18:03

>>19
Oh, don't worry about that. There's always lots of posers around.

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?

Name: Anonymous 2010-10-23 5:19

>>21
Why would you split a simple function like factorial into two functions?

Name: Anonymous 2010-10-23 10:52

>>22
>>1 complaining about one-liners.

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.

Name: Anonymous 2010-10-23 13:57

(define (factorial n)
    (loop ((for i (up-from 1 (to (+ n 1))))
           (for x (multiplying i)))
          => x))

Name: Anonymous 2010-10-23 16:23

(define (factorial n) (loop ((for i (up-from 1 (to (+ n 1)))) (for x (multiplying i))) => x))

Name: Anonymous 2010-10-23 16:23

inb4 someone posts the Haskell one-liner for it

Name: Anonymous 2010-12-24 22:17


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