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

Pages: 1-

DOCTOR SCHEME

Name: Anonymous 2008-12-10 14:33

(define (pow X N)
  (cond
   ((= N 0) 1)
   ((> N 0) (* X (pow X (- N 1))))
   )
  )

(define (countAtoms X)
  (cond
    ((null? X)
     0)
    ((list? X)
     (cond
       ((list? (car X))
        (+ (countAtoms (cdr X)) (countAtoms (car X))))
       (else
        (+ (countAtoms (cdr X)) 1)))
     )
    )
  )

(define (cons2 X Y)
  (cond
    ((null? X)
     (cons Y ()))
    ((not(pair? X))
     (cons X (cons Y ())))
    (else
     (cons (car X) (cons2 (cdr X) Y)))
    )
  )

(define (reverse X)
  (cond
    ((null? X) ())
    ((null? (cdr X))
     (car X))
    ((list? X)
     (cond
       ((list? (car X))
        (cons2 (reverse (cdr X)) (reverse(car X))))
       (else
        (cons2 (reverse (cdr X)) (car X)))))
    )
  )

Name: Anonymous 2008-12-10 14:37

No, this is not how you learn Scheme.

Name: Anonymous 2008-12-10 14:48

Sorry I messed up reverse here is the working version


(define (reverse X)
  (cond
    ((null? X) ())
    ((list? X)
     (cond
       ((list? (car X))
        (cons2 (reverse (cdr X)) (reverse(car X))))
       (else
        (cons2 (reverse (cdr X)) (car X)))))
    )
  )

Name: Anonymous 2008-12-10 14:53

What's the point of a cons2 that uses cons? Also, place your parentheses like everyone else. The way you do it screams out ``I HAVEN'T READ MY SICP TODAY!''

Name: Anonymous 2008-12-10 15:02

cons2 is like a reverse cons

cons x y gives a list with x as the first atom/list and y as the rest of the list after x

cons2 gives a list where x is the last atom/list and y is the stuff before x

I was taught scheme 2 days ago and don't know a better way to do it...

I don't know how other people put their parentheses.

Also;
[quote]I HAVEN'T READ MY SICP [s]TODAY[/s] EVER[/quote]

Name: Anonymous 2008-12-10 15:04

Have you read your

Recursive Functions of Symbolic Expressions
  and Their Computation by Machine, Part I
John McCarthy, Massachusetts Institute of Technology, Cambridge, Mass.
                       April 1960


today?

Name: Anonymous 2008-12-10 17:57

>>5
I don't know how other people put their parentheses.
How have you written this code without ever seeing anyone else's code?

Name: Anonymous 2008-12-10 22:02

>>7
I prefer >>5's style, the closing parens should be aligned with the opening parens. Forced indentation of the parentheses, etc.

Name: Anonymous 2008-12-10 22:16

>>8
That's because you don't write Lisp. Anyone who does quickly comes to realize that putting parens on new lines is just ugly and a waste of screen space.

Name: Anonymous 2008-12-10 22:34

>>9
No, it's because I don't use a faggy editor with paren matching like yours.

Name: Anonymous 2008-12-10 22:44

>>10
You would if you programmed in Lisp. Enjoy your notepad.exe.

Name: Anonymous 2008-12-11 0:13

>>11
Enjoy your crutches designed to cover up mediocre programming skills.

Name: Anonymous 2008-12-11 0:39

>>12
If you consider paren matching a ``programming skill'', I'd hate working with you.

Name: Anonymous 2008-12-11 1:51

>>13
If you consider faggot quotes quotation marks, I'd hate working with you.

Name: Anonymous 2008-12-11 4:25

I will, along with my job.

Name: Anonymous 2008-12-11 4:34

Don't mind me, just balancing some parentheses.

))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

Name: Anonymous 2008-12-11 8:01

>>15
There are no jobs writing LISP.

Name: Anonymous 2008-12-11 8:11

>>17
That's because Lisp is not relevant for doing any actual work.

Name: Anonymous 2008-12-11 12:01

sicp is a meme

Name: Anonymous 2008-12-11 15:38

DOKTOR SCHEEM

Name: Anonymous 2008-12-11 18:46

Beware. He is not a real doctor.

Name: Anonymous 2008-12-11 19:09

>>21
This, oh god this.
Do NOT let him touch your genitals.

Name: Anonymous 2009-03-06 12:45


Perl is way easier and believe me   I understand Smalltalk   or Lisp which   is a language   The only thing   that works for   you Just be   a new revision   of the language   itself conflates methods   and messages No.

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