Thanks Mike.

When I apply the procedure to 'John it will evaluate to 'symbol. The idea 
of the procedure is to check the "type" of the given item, which is not 
decided aprior. If I give it 'John I know it is a symbol.
May be my question should be formulated as this: Since John is not a pair, 
an empty-list, a number, not a symbol, why the execution doesn't proceed to 
the else expression no matter what John is, unless you are telling me that 
the item given to the procedure is evaluated first.


On Sunday, January 13, 2019 at 6:58:45 AM UTC+2, Mike MacHenry wrote:
>
> You need to apply the function to 'John, with a single quote in front of 
> it. The word John without that quote is just a variable reference to 
> something that you have not actually defined. 
>
> On Sat, Jan 12, 2019 at 11:34 PM Hassan Shahin <hsh...@gmail.com 
> <javascript:>> wrote:
>
>> I have this definition for a procedure:
>>
>> (define type-of (lambda (item)
>>                          (cond
>>                            [(pair? item) 'pair]
>>                            [(null? item) 'empty-list]
>>                            [(number? item) 'number]
>>                            [(symbol? item) 'symbol]
>>                            [else 'some-other-type])))
>>
>> My understanding is that if the first 4 conditions fail (=> #f 
>> <https://plus.google.com/s/%23f/posts>), then the last expression (the 
>> else expression) is evaluated. 
>> When I apply this procedure to John, as in (type-of John) I get an error 
>> (; john: undefined; ; cannot reference an identifier before its 
>> definition). 
>>
>> What is going on?
>> Thanks
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> 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