On Wed, Sep 23, 2015 at 11:40 PM, Alexis King wrote:
>
> Er, no you can’t... `begin` doesn’t create an internal definition context
> (or even a new scope). You can use an empty `let` instead:
>
> (define (f x)
> (if (even? x)
> (/ x 2)
> (let ()
> (define a (* x 2))
>
> Ok. Yeah, if- branches aren't allowed to have definitions, or even sequences
> of operations. You can get around this with begin
Er, no you can’t... `begin` doesn’t create an internal definition context (or
even a new scope). You can use an empty `let` instead:
(define (f x)
(if (even? x)
Very neat! Thank you! Best -Kaushik
On Wed, Sep 23, 2015 at 7:46 PM, Benjamin Greenman <
benjaminlgreen...@gmail.com> wrote:
>
> On Wed, Sep 23, 2015 at 7:38 PM, Kaushik Ghose
> wrote:
>
>> I haven't gotten to cond yet.
>
>
> Ok. Yeah, if- branches aren't allowed to have definitions, or even
> s
On Wed, Sep 23, 2015 at 7:38 PM, Kaushik Ghose
wrote:
> I haven't gotten to cond yet.
Ok. Yeah, if- branches aren't allowed to have definitions, or even
sequences of operations. You can get around this with begin:
(define (f x)
(if (even? x)
(/ x 2)
(begin
(define a (* x
PS
On Wed, Sep 23, 2015 at 7:38 PM, Kaushik Ghose
wrote:
> Hi!
>
> On Wed, Sep 23, 2015 at 7:33 PM, Benjamin Greenman <
> benjaminlgreen...@gmail.com> wrote:
>
>> Could you post the "ugly" code? I'm curious because things like this
>> compile fine:
>>
>> The ugly code looks like:
(define (f x)
Hi!
On Wed, Sep 23, 2015 at 7:33 PM, Benjamin Greenman <
benjaminlgreen...@gmail.com> wrote:
> Could you post the "ugly" code? I'm curious because things like this
> compile fine:
>
> (define (f-recur x y)
> (cond ((< x 1)
> 10)
> (else
>(define z 3)
>(f-recur x y
>
> I'm d
Could you post the "ugly" code? I'm curious because things like this
compile fine:
(define (f-recur x y)
(cond ((< x 1)
10)
(else
(define z 3)
(f-recur x y
On Wed, Sep 23, 2015 at 7:25 PM, Kaushik Ghose
wrote:
>
> On Wed, Sep 23, 2015 at 12:26 PM, Pierpaolo Bernardi
>> wro
> On Wed, Sep 23, 2015 at 12:26 PM, Pierpaolo Bernardi
> wrote:
>
>> On Wed, Sep 23, 2015 at 6:18 PM, Kaushik Ghose
>> wrote:
>>
>> > Can I have any statements in this block that I could have in a (define
>> ...)
>> > block? Can I have (defines ) for example?
>>
>> Yes, and yes :)
>>
>
> Hmm. I
Thank you very much for your help! Best -Kaushik
On Wed, Sep 23, 2015 at 12:26 PM, Pierpaolo Bernardi
wrote:
> On Wed, Sep 23, 2015 at 6:18 PM, Kaushik Ghose
> wrote:
>
> > Can I have any statements in this block that I could have in a (define
> ...)
> > block? Can I have (defines ) for example
On Wed, Sep 23, 2015 at 6:18 PM, Kaushik Ghose wrote:
> Can I have any statements in this block that I could have in a (define ...)
> block? Can I have (defines ) for example?
Yes, and yes :)
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
T
Hi!
Thanks for your reply.
> (define (f-recur x y)
> (cond ((< x 1)
> 10)
> (else
>... something complex
> (f-recur x' y'
>
Can I have any statements in this block that I could have in a (define ...)
block? Can I have (defines ) for e
On Wed, Sep 23, 2015 at 3:20 PM, Kaushik Ghose wrote:
> e.g.
>
> (define (f-recur x y)
> (if (< x 1)
> 10
> (f-recur-2 x y)))
>
> (define (f-recur-2 x y)
> ... something complex here
> (f-recur x' y')
(define (f-recur x y)
(cond ((< x 1)
10)
(else
12 matches
Mail list logo