guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: two elementary questions -- corrected


From: Martin Grabmueller
Subject: Re: two elementary questions -- corrected
Date: Wed, 12 Dec 2001 13:23:11 +0100 (MET)

> From: "KELLEHER,KEVIN (Non-HP-Roseville,ex1)" <address@hidden>
> Date: Tue, 11 Dec 2001 14:41:38 -0500
> 
> 
> 1.  What is the difference in meaning between these two expressions?
> 
>       (lamdba x  x)
>       (lambda (x) x)

The first is a function taking zero or more arguments, which will be
bound to `x' as a list, whereas the second takes exactly one argument.
Both simply return their argument, which will be a list of all
arguments for the former and a single value (the argument) for the latter.

> 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) (list (cdr x))))))
> 
> (list 1 2 3 4) => (1 (2 3 4)), but I want (1 2 3 4).

The first function above in 1. is the `list' function, because it
returns all arguments as a list.

Best regards,
  'martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]