Re: [racket-users] Questions on HtDP 2e, Ex. 356
Hi Ben, as Jens has pointed out, it pays off to read the context of an exercise (like in the real world). The second exercise states > If the terminology poses any difficulties, do re-read BSL Grammar. where “BSL Grammar” is a link that explains BSL via a data definition (that’s what a grammar is) and explains the terminology of — function application — function definition which are TWO distinct concepts. Sadly, math teachers gloss over this distinctions in school (if they know it) and other teachers do not know it. In computing, especially programming, precise terminology is critical so that you can efficiently communicate with others. After all, programming is a people discipline not a cubicle sport (even if you do sit in a cubicle in many shops; but that’s because of many other problems). So for your sake, I urge you to catch up on Intermezzo I so that you understand these distinctions. Having said that, I will move this sentence (hint) to the preceding exercise so that others don’t get hung up on this terminology issue. — Matthias p.s. This explanation does probably not apply to people who just wish to learn to code and remain cheap rent-a-coders. But that’s a path they should choose after experiencing this fate for a couple of years in a company. > On Jul 12, 2017, at 10:58 PM, Ben Morinwrote: > > Hi Jens > > Thanks for the reply. > > I was working through it with some free time today, and I think my data > definition works. The other big problem I was having was the body for the > user-defined function. As you said, ex 356 isn't concerned about that aspect. > This is what was/is throwing me off. My assumption is now that I would define > the body of an arbitrary function in the arguments of eval-definition1. > > For instance: > > (eval-definition1 '(by-five (make-add 1 1)) 'by-five 'p (make-mul 5 'p)) > > The first arg being the expression to evaluate. > Second is the function name being evaluated for. > Third being 'by-five's parameter. > Fourth being the actual body of 'by-five. > > The result of eval-definition1 then being 10. > > I hope this is heading in the right direction. > > -- > 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. -- 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.
Re: [racket-users] Questions on HtDP 2e, Ex. 356
> I hope this is heading in the right direction. Looks fine to me. -- 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.
Re: [racket-users] Questions on HtDP 2e, Ex. 356
Hi Jens Thanks for the reply. I was working through it with some free time today, and I think my data definition works. The other big problem I was having was the body for the user-defined function. As you said, ex 356 isn't concerned about that aspect. This is what was/is throwing me off. My assumption is now that I would define the body of an arbitrary function in the arguments of eval-definition1. For instance: (eval-definition1 '(by-five (make-add 1 1)) 'by-five 'p (make-mul 5 'p)) The first arg being the expression to evaluate. Second is the function name being evaluated for. Third being 'by-five's parameter. Fourth being the actual body of 'by-five. The result of eval-definition1 then being 10. I hope this is heading in the right direction. -- 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.
Re: [racket-users] Questions on HtDP 2e, Ex. 356
Hi Ben, Adding syntax for both applications, user defined functions and adding evaluation of these in the same execise, is a bit much. It is therefore split up into exercise 356, 357, 358 and 359. Exercise 356 is only about extending the data definition such that applications can be represented. In excercise 357 eval-definition1 receives as one of its argument the function (including the body) of the user defined function. /Jens Axel 2017-07-12 15:41 GMT+02:00 Ben Morin: > I've been working my way through HtDP on and off over the past several > months. I've generally been able to figure it out on my own (even if it > takes awhile). However, Intertwined Data has given me a couple problems > that I just can't seem to wrap my head around. > > The major one is 21.3 "Interpreting Functions." > http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/part_ > four.html#%28counter._%28exercise._ex~3absl-one-def%29%29 > > Exercise 356 asks to extend the data definition of > > ; A BSL-var-expr is one of: > ; – Number > ; – Symbol > ; – (make-add BSL-var-expr BSL-var-expr) > ; – (make-mul BSL-var-expr BSL-var-expr) > > to "include application of a programmer-defined function," which is a > function name and expression, My first thought was something in line with > the rest of the chapter: > > (make-func [name expr]) > > But looking at examples like (k (+ 1 1)) makes it seem like the data > definition should just incorporate a name and an argument. Where does the > function's body come into play? > > Exercise 357 then asks to create a function with the following parameters: > - a BSL-Func-Expr, would this be just (k (+ 1 1))? > - the function name, k? > - the function parameters, (+ 1 1) is the argument? > - the function body, ... (+ 1 1)? > > How can a user-defined function like "k" be evaluated if only its argument > is known? > > I feel like I read this, understand the words, but can't comprehend the > sentences. > > > Thanks in advance > > -- > 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. > -- -- Jens Axel Søgaard -- 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.
[racket-users] Questions on HtDP 2e, Ex. 356
I've been working my way through HtDP on and off over the past several months. I've generally been able to figure it out on my own (even if it takes awhile). However, Intertwined Data has given me a couple problems that I just can't seem to wrap my head around. The major one is 21.3 "Interpreting Functions." http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/part_four.html#%28counter._%28exercise._ex~3absl-one-def%29%29 Exercise 356 asks to extend the data definition of ; A BSL-var-expr is one of: ; – Number ; – Symbol ; – (make-add BSL-var-expr BSL-var-expr) ; – (make-mul BSL-var-expr BSL-var-expr) to "include application of a programmer-defined function," which is a function name and expression, My first thought was something in line with the rest of the chapter: (make-func [name expr]) But looking at examples like (k (+ 1 1)) makes it seem like the data definition should just incorporate a name and an argument. Where does the function's body come into play? Exercise 357 then asks to create a function with the following parameters: - a BSL-Func-Expr, would this be just (k (+ 1 1))? - the function name, k? - the function parameters, (+ 1 1) is the argument? - the function body, ... (+ 1 1)? How can a user-defined function like "k" be evaluated if only its argument is known? I feel like I read this, understand the words, but can't comprehend the sentences. Thanks in advance -- 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.