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-30 2:27 ID:5O6yxmbE

Since I don't have an interpreter and XLisp doesn't want to download... I haven't tested this code

I actually never met "display" in Scheme... and the quoted parenthesis are not what professors expect. Someone else can probably check and expand on this idea below. You may need a final check for the empty list, because I'm not sure if it causes "more" of the list evaluated:

(define (dumplist list)
   (if (atom? list)
        'list # return the current value
        (dumplist (cdr list))  # recursion here to evaluate rest
   )
)

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