[racket] WeScheme cond branch error

From: Ashok bakthavathsalam (lifebalance at gmail.com)
Date: Sun Jun 10 13:18:50 EDT 2012

Sogaard's solution (and one other) is available as a answer on SO at http://stackoverflow.com/questions/10968655/scheme-code-cond-error-in-wescheme 

Thanks, 

On 10-Jun-2012, at 17:51, Jens Axel Søgaard <jensaxel at soegaard.net> wrote:

> Use local for internal definitions in the teaching languages.
> 
> http://docs.racket-lang.org/htdp-langs/advanced.html?q=local#(form._((lib._lang/htdp-advanced..rkt)._local))
> 
> /Jens Axel
> 
> 
> 
> 2012/6/10 Ashok Bakthavathsalam <ashokb at kggroup.com>:
>> Although the following code works perfectly well in DrRacket environment, it
>> generates the following error in WeScheme:
>>   Inside a cond branch, I expect to see a question and an answer, but I see
>> more than two things here.
>> 
>>      at: line 15, column 4, in <definitions>
>> 
>> 
>> How do I fix this? The actual code is available
>> at http://www.wescheme.org/view?publicId=gutsy-buddy-woken-smoke-wrest
>> 
>> (define (insert l n e)
>>   (if (= 0 n)
>>       (cons e l)
>>       (cons (car l)
>>             (insert (cdr l) (- n 1) e))))
>> 
>> (define (seq start end)
>>   (if (= start end)
>>       (list end)
>>       (cons start (seq (+ start 1) end))))
>> 
>> (define (permute l)
>>   (cond
>>     [(null? l) '(())]
>>     [else (define (silly1 p)
>>             (define (silly2 n) (insert p n (car l)))
>>             (map silly2 (seq 0 (length p))))
>>             (apply append (map silly1 (permute (cdr l))))]))
>> 
>> 
>> 
>> 
>> 
>> 
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>> 
> 
> 
> 
> -- 
> --
> Jens Axel Søgaard
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users


Posted on the users mailing list.