Re: [racket-users] Help understanding cond expression

2019-01-15 Thread Michael Murdock MacLeod
On Saturday, January 12, 2019 8:34:35 PM PST Hassan Shahin wrote: > I have this definition for a procedure: > > (define type-of (lambda (item) > (cond >[(pair? item) 'pair] >[(null? item) 'empty-list] >

Re: [racket-users] Help understanding cond expression

2019-01-12 Thread Hassan Shahin
Thanks Jon. yes. I did, and you are right. I posted the same question a Google+ forum (https://plus.google.com/108613325307702875646/posts/1BaDJFoat4D), and I also got a reply that: "John is being parsed as a variable, and thus, its binding is looked up in the local environment. Of course,

Re: [racket-users] Help understanding cond expression

2019-01-12 Thread Jon Zeppieri
On Sun, Jan 13, 2019 at 12:37 AM Hassan Shahin wrote: > Thanks Jack and Mike! > > You are right. Arguments to procedures will be evaluated before the > invocation of the procedure. > This is true, but it's not really the issue in your case. Even in #lang lazy, which does not eagerly evaluate

Re: [racket-users] Help understanding cond expression

2019-01-12 Thread Hassan Shahin
Thanks Jack and Mike! You are right. Arguments to procedures will be evaluated before the invocation of the procedure. I thought that because (if) is not an ordinary procedure, and because one can express if in terms of cond (or vice versa) that my procedure is also a non ordinary procedure,

Re: [racket-users] Help understanding cond expression

2019-01-12 Thread Jack Rosenthal
On Sat, 12 Jan 2019 at 21:12 -0800, Hassan Shahin wrote: > 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

Re: [racket-users] Help understanding cond expression

2019-01-12 Thread Hassan Shahin
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

Re: [racket-users] Help understanding cond expression

2019-01-12 Thread Mike MacHenry
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 wrote: > I have this definition for a procedure: > > (define

[racket-users] Help understanding cond expression

2019-01-12 Thread Hassan Shahin
I have this definition for a procedure: (define type-of (lambda (item) (cond [(pair? item) 'pair] [(null? item) 'empty-list] [(number? item) 'number] [(symbol?