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

Halp how do i programmed scheme

Name: Anonymous 2007-03-26 12:29 ID:e6O5XmtL

I'm trying to make a program that prints out the contents of a list.

     (define (dumplist list)
          (car list)
          (cond (null? (cdr list))
               (else
                    (dumplist (cdr list)))))

However, this doesn't work. Instead it just prints (cdr list)

Name: Anonymous 2007-03-26 16:22 ID:Mg9RfV9G

No that is terribly unscheme like, you should do:


(define (display-list list)
 (display "( ")
 (map (lambda (element)
              (if (not (list? element)) (display element)
                                        (display-list element))
              (display " ")) list)
 (display ")"))

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