Hi Scott, On Sat, 28 Jun 2014 12:05:39 -0700 Steve Graham <[email protected]> wrote:
> When you're writing your program, do you enter statements in the top > window or in the bottom one? I'm not much of a DrRacket user myself. Nevertheless, it has nice features. In DrRacket you enter definitions in the top window and you interact with those definitions in the bottom window. So for instance this (define (g x) (+ 1 x)) (define (f x) (* x (g x))) would go to the top window. Then this (f 5) would go to the bottom window. > Do you have to define a function first > before including it in another function? > I think this is not required. If you put the stuff from above in a file like this (this could be invoked at the command line by using racket at the command line): <----------------snip---------------------> #lang racket/base (define (g x) (+ 1 x)) (define (f x) (* x (g x))) (f 5) <----------------snap---------------------> then it doesn't matter if the definition of f comes before g or vice versa. Important is that the invocation of f comes last. Racket is lexically scoped means if you invoke something then the stuff you invoke must have been defined before your invoke it. Take above example and write it this way: (define (f x) (* x (g x))) (f 4) (define (g x) (+ 1 x)) Now you would get an error because invocation of f requires f to be defined before (this is given) but now f requires g (as it is called inside), and g isn't defined yet. -- Manfred ____________________ Racket Users list: http://lists.racket-lang.org/users

