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 2012-04-03 19:32

>>44

oops, sorry that doesn't work -- better version

#lang racket

(define (flip f)
  (lambda (x y)
    (f y x)))

(define list->strings
  (curry map (compose (curry (flip
                              string-append) "\n")
                      (lambda (x)
                        (match x
                          [(? number?) (number->string x)]
                          [(? string?) x]
                          [list (dump-list x)])))))

(define dump-list (compose
                   (curry (flip string-join) "")
                   list->strings))

(display (dump-list (list 1 2 3 "sup" (list 1 2 3))))

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