chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] scheme student perplexed by failures ...


From: Thomas Chust
Subject: Re: [Chicken-users] scheme student perplexed by failures ...
Date: Sun, 12 Aug 2012 02:01:31 +0200 (CEST)
User-agent: Alpine 2.02 (LNX 1266 2009-07-14)

On Sat, 11 Aug 2012, john saylor wrote:
[...]
and here is my propsed solution:
define js-reverse
   (lambda (ls)
       ((reverse-rec ls '()))))
[...]

Hello John,

your code above lacks an opening paranthesis before the define and it has an extraneous pair of parentheses around the call to reverse-rec.

[...]
(define js-reverse-rec
   (lambda (asc dsc)
       ((if (null? asc)
           dsc
           ;(js-reverse-rec (cdr asc) (list dsc (car asc)))))))
           (js-reverse-rec (cdr asc) (cons (car asc) dsc))))))
[...]

Again, there is an extraneous pair of parentheses around the use of the if syntax.

In Scheme, parentheses are relevant syntax that indicate uses of syntax or calls to procedures. The expression

  ((reverse-rec ls '()))

means

  "Call reverse-rec with the arguments ls and '(), then call the result
   with no arguments."

Since the results of reverse-rec and of the conditional in js-reverse-rec are not procedures but lists, these extra calls you programmed cause the type errors you see.

Ciao,
Thomas


--
When C++ is your hammer, every problem looks like your thumb.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

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