[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
spread vs. nospread
From: |
Joshua Judson Rosen |
Subject: |
spread vs. nospread |
Date: |
Tue, 11 Dec 2001 15:29:51 -0500 |
User-agent: |
Mutt/1.3.24i |
On Tue, Dec 11, 2001 at 09:58:49AM -0800, KELLEHER,KEVIN (Non-HP-Roseville,ex1)
wrote:
>
> 1. What is the difference in meaning between these two expressions?
>
> (lamdba x x)
> (lambda (x) x)
The second (spread) function accepts one argument, and returns that value.
The first (nospread) function accepts any number of arguments, and returns the
list of values.
If you were using the short-hand `define' syntax, your your forms would be
equivalent to:
(define (f . x) x) ; equivalent to (lambda x x)
(define (f x) x) ; equivalent to (lambda (x) x)
> 2. I've been doing the exercises in a learning-scheme book, and one is
> to implement the "list" function. What is wrong here?
>
> (define (list . x)
> (cond
> ((null? x) '())
> ((null? (cdr x)) x)
> (else (cons (car x) (ll (cdr x))))))
First off..., what is this `ll' function?
> (list 1 2 3 4) => (1 (2 3 4)), but I want (1 2 3 4).