> On Jan 23, 2018, at 1:03 PM, Matthias Felleisen <matth...@felleisen.org> 
> wrote:
> 
> 
> Huh? Serves you right for using the top level. It works fine if you place it 
> in the definitions window :-) 

Of course, and that’s what I told the poster on Stack Exchange. I was befuddled 
by the existing behavior, but I explicitly mentioned that the solution was not 
to use the top-level.

John

> 
>> Welcome to DrRacket, version 6.11.0.4--2017-12-18(-/f) [3m].
>> Language: racket, with debugging; memory limit: 256 MB.
>>> (map '() add1)
>> '()
>>> (map '(1) add1)
>> '(2)
>>> (map '(1 2) add1)
>> '(2 3)
>>> (map '(1 2 3) add1)
>> '(2 3 4)
>>> 
> 
> 
> — Matthias
> 
> 
> 
>> On Jan 23, 2018, at 3:57 PM, 'John Clements' via Racket Users 
>> <racket-users@googlegroups.com> wrote:
>> 
>> Stack overflow today led me to something … very strange. I feel like I must 
>> be missing something crushingly obvious.
>> 
>> To reproduce: start racket at the command line or hit “run” on a definitions 
>> window containing only “#lang racket”.
>> 
>> Then, paste:
>> 
>> (define map (lambda (l f)
>>   (cond
>>       ((null? l) '())
>>       (else (cons (f (car l)) (map (cdr l) f)))
>>   )
>> ))
>> 
>> (Note that this version of map takes the function last.) Then, paste:
>> 
>> (map '(3 4 5) add1)
>> 
>> See this error:
>> 
>> map: contract violation
>> expected: procedure?
>> given: '(4 5)
>> argument position: 1st
>> other arguments…:
>> 
>> Note that the error occurs on the recursive call. This means that despite 
>> being inside of a binding of the name map, the function is using the 
>> built-in function.
>> 
>> When I try doing the same thing with a value defined in the empty program 
>> (with the name’f’), I see the error 
>> 
>> define-values: assignment disallowed;
>> cannot re-define a constant
>> constant: f
>> 
>> Which leads me to the suspicion that maybe possibly this message is supposed 
>> to be shown for the re-definition of ‘map’, as well?
>> 
>> Very confused,
>> 
>> John
>> 
>> 
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
> 



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to