[plt-scheme] Re: create a board with vector

From: David Yrueta (dyrueta at gmail.com)
Date: Mon Dec 7 01:02:46 EST 2009

Hi Mona --

It looks like you're working on the Checking Queens exercise in HtDP.

If that's the case, there is one exercise in Section IV whose solution
is very similar to the build-board function you are trying to design.
If you have already worked through all previous exercises, I would
suggest reviewing that section in detail.  If not, then I'd recommend
starting from the beginning of that section, working through all the
exercises, and then returning to Checking Queens.  The exercise I'm
referring to should jump out at you.

Good luck!

Dave Yrueta

On Sun, Dec 6, 2009 at 2:44 PM, Synx <plt at synx.us.to> wrote:
> Mona wrote:
>> build_vctor has 2 inputs, it seems one of the inputs is n and the
>> other is (lamda (i) (f i j)). I cant understand what (lamda (i) (f i
>> j))   will produce.
> (lambda (i) (f i j)) will produce a procedure. When that procedure is
> applied with a single argument, that procedure will then apply the
> procedure 'f', with two arguments, the one passed, and whatever 'j' is
> in the lexical scope.
> So (define foo (lambda (i) (+ i 3)) will define foo to be a procedure,
> such that nothing happens, but when you go (foo 2) it calls (+ 2 3) and
> returns 5.
> Similarly (define foo (let ((j 3)) (lambda (i) (+ i j)))) will do the
> same thing. It defines foo to be a procedure, but while creating that
> procedure it binds 'j' to the value 3 using the "let" syntax. The let
> syntax just returns whatever's inside it, so it's just like (lambda (i)
> (+ i 3)) except that inside the (let ...) lexical scope, j can be used
> instead of 3.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.