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

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 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?

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