Re: [racket-users] From HtDP to Racket
Thanks for the point. It's a good one. I'm in the process of a new re-ordering and rewriting. In the meantime I'm going to follow your suggestion of putting a link at the end of each post. A link before the code may be misleading, though. I want readers go through the code. I should have explained what *SL languages are when posting on the forum, yes. In the blog this is commented. I expect all readers are aware of HtDP, and so of what BSL, ISL, ... are. -- 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] From HtDP to Racket
There is a TOC at the beginning of the post, but I'd add a link to the next post at the end. Something like: "Next article in the series: From HtDP to Racket. Racket (2): only-in, rackunit, test submodules" I'd put one at the very end and other just before the code. Gustavo PS: As other user said, it would be good to explain once what BSL, ISL, ... are. On Thu, Apr 18, 2019 at 1:08 PM Luis Sanjuán wrote: > The last month or so we all read some interesting posts about the > convenience of examples or docs to facilitate the transition from other > languages to Racket (from Python to Racket, from R to Racket, ...). Then I > thought about another non-Racket languages that no one mention, if I recall > well, for which such examples would be more than helpful, *SL languages ;) > > Of course, The Realm is there, but more examples would be beneficial, I > guess. I have written something along these lines on my blog: > > > https://los-pajaros-de-hogano.blogspot.com/2019/04/from-htdp-to-racket-isbn-extraction-in.html > > It might be full of inaccuracies or even errors. So comments, fixes, or > suggestions are welcomed. > > -- > 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] From HtDP to Racket
Matthias, thank you very much for taking the time to carefully read the whole thing and for your thoughtful suggestions. Most, if not all of them, put on the foreground my own doubts and misgivings. On Saturday, April 20, 2019 at 8:19:31 PM UTC+2, Matthias Felleisen wrote: > > > > > On Apr 18, 2019, at 12:08 PM, Luis Sanjuán > wrote: > > > > The last month or so we all read some interesting posts about the > convenience of examples or docs to facilitate the transition from other > languages to Racket (from Python to Racket, from R to Racket, ...). Then I > thought about another non-Racket languages that no one mention, if I recall > well, for which such examples would be more than helpful, *SL languages ;) > > > > Of course, The Realm is there, but more examples would be beneficial, I > guess. I have written something along these lines on my blog: > > > > > https://los-pajaros-de-hogano.blogspot.com/2019/04/from-htdp-to-racket-isbn-extraction-in.html > > > > > It might be full of inaccuracies or even errors. So comments, fixes, or > suggestions are welcomed. > > > > > Luis, this is great. Thank you for the effort. > > Here are some suggestions on how I’d re-order some of the material: > > 0. Importing all of racketbase and racket/string and racket/file first is > questionable. I would create a teachpack > > htdp2racket > > that includes the functions that are needed for writing such excerpts of > realistic programs. I’d be happy to collaborate on this and include the > teachpack with 2htdp. racket/file requirement can be easily replaced with your read-file (2htdp/batch-io) As for racket/string, all the functions needed, if not in their full generality, at least to the extent required by the task, can be defined in ISL, and replaced with Racket string functions in a later step. Regexes pose a more demanding challenge. I really thought of it, and even tried to some extent other alternatives too: (a) Begin with a solution to HtDP ex. 476 (fsm-match) and extend it to deal with quantifiers. Maybe this reduced regex support would be enough for the task. The problem with this is that this adds heavy burden to the task. (b) Tackle the problem assuming that each ISBN appears in its own line, as the standard specifies. Under this assumption it is possible to devise this strategy: 1. Read words per line. 2. Join consecutive words consisting of ISBN letters (digits or 'X'). 3. Remove separators from the result. 4. Validate each word. I think that this should work for the problem without the need of regexes. >From there on regexes could be introduced as another way of solving the task in Racket, or I could stick to the initial strategy and present it in Racket, using regexes sparingly if needed. What do you think about these alternatives? Anyway, a teachpack is another option. I really appreciate your offer of making it possible :-) > > > 1. I’d switch to #lang htdp/isl+ first. Your code should pose no problems > for this #lang. (It isn’t production ready yet). > > 2. Still in ISL+, I would add the 2htdp/abstraction teachpack to simplify > the ISLcode first. I think its suport of for and match fits. > > I did so in a prior draft. I can return to that, and show full-fledged Racket 'for' later. > 3. A re-factoring of code must have the support of a test suite. There are > three ways to go about this: > > (a) import rackunit into ISL+ > (b) import racket-tests/test-engine into the racket/base program > and run (test) at the bottom > (c) rewrite the tests into rackunit + submdoule. > > I’d go with (b) and do an optional last step to show people how to write > idiomatic rackunit tests. > > Definitely fair complaint. Exposition order shouldn't affect basic program design principles. > 4. I would not use define/contract for this transition sequence. See > elsewhere for its somewhat complex semantics when it comes to blame > assignment. Instead when you use contracts, it might be a good time to > split the module into two parts: > > — the main functions > — the helpers and the large number of constant definitions plus > contracts (yes export the contracts from here if you can keep things > opaque) > > You could first show how to move code into a submodule with its own > contract-out plus a single require, then move the submodule into a file. > (That’s how I proceed and it should be a DrRacket refactoring operation.) > > I'm aware of define/contract caveats (Guide 7.9.2). Splitting things into two modules looks indeed the soundest solution here. > > 5. Years ago, I observed a PhD in our lab using point-free style in > Racket. He came from Haskell of course. I tried it. I got close to saying > negative things about it in the style guide. > > That was a Haskellian whim, and I'm going to correct it. Actually, function composition and curried functions are introduced somewhere else, when
Re: [racket-users] From HtDP to Racket
On 4/20/19, Hendrik Boom wrote: > On Thu, Apr 18, 2019 at 09:08:07AM -0700, Luis Sanjuán wrote: >> Then I thought about another non-Racket languages that no one >> mention, if I recall well, for which such examples would be more than >> helpful, *SL languages ;) > > What are *SL languages? Those are the student languages for HTDP https://docs.racket-lang.org/htdp-langs/ Or rather, *SL is a short name for the short names for the student languages. (BSL = beginning student language, etc.) -- 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] From HtDP to Racket
On Thu, Apr 18, 2019 at 09:08:07AM -0700, Luis Sanjuán wrote: > Then I thought about another non-Racket languages that no one > mention, if I recall well, for which such examples would be more than > helpful, *SL languages ;) What are *SL languages? -- Hendrik -- 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] From HtDP to Racket
> On Apr 18, 2019, at 12:08 PM, Luis Sanjuán wrote: > > The last month or so we all read some interesting posts about the convenience > of examples or docs to facilitate the transition from other languages to > Racket (from Python to Racket, from R to Racket, ...). Then I thought about > another non-Racket languages that no one mention, if I recall well, for which > such examples would be more than helpful, *SL languages ;) > > Of course, The Realm is there, but more examples would be beneficial, I > guess. I have written something along these lines on my blog: > > https://los-pajaros-de-hogano.blogspot.com/2019/04/from-htdp-to-racket-isbn-extraction-in.html > > It might be full of inaccuracies or even errors. So comments, fixes, or > suggestions are welcomed. Luis, this is great. Thank you for the effort. Here are some suggestions on how I’d re-order some of the material: 0. Importing all of racketbase and racket/string and racket/file first is questionable. I would create a teachpack htdp2racket that includes the functions that are needed for writing such excerpts of realistic programs. I’d be happy to collaborate on this and include the teachpack with 2htdp. 1. I’d switch to #lang htdp/isl+ first. Your code should pose no problems for this #lang. (It isn’t production ready yet). 2. Still in ISL+, I would add the 2htdp/abstraction teachpack to simplify the ISLcode first. I think its suport of for and match fits. 3. A re-factoring of code must have the support of a test suite. There are three ways to go about this: (a) import rackunit into ISL+ (b) import racket-tests/test-engine into the racket/base program and run (test) at the bottom (c) rewrite the tests into rackunit + submdoule. I’d go with (b) and do an optional last step to show people how to write idiomatic rackunit tests. 4. I would not use define/contract for this transition sequence. See elsewhere for its somewhat complex semantics when it comes to blame assignment. Instead when you use contracts, it might be a good time to split the module into two parts: — the main functions — the helpers and the large number of constant definitions plus contracts (yes export the contracts from here if you can keep things opaque) You could first show how to move code into a submodule with its own contract-out plus a single require, then move the submodule into a file. (That’s how I proceed and it should be a DrRacket refactoring operation.) 5. Years ago, I observed a PhD in our lab using point-free style in Racket. He came from Haskell of course. I tried it. I got close to saying negative things about it in the style guide. I am a bit disappointed that the code didn't shrink during the transformation but I didn’t spot immediate big gains, even with some small style guide things fixed. Again, thank you very much and please keep posting — Matthias -- 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] From HtDP to Racket
The last month or so we all read some interesting posts about the convenience of examples or docs to facilitate the transition from other languages to Racket (from Python to Racket, from R to Racket, ...). Then I thought about another non-Racket languages that no one mention, if I recall well, for which such examples would be more than helpful, *SL languages ;) Of course, The Realm is there, but more examples would be beneficial, I guess. I have written something along these lines on my blog: https://los-pajaros-de-hogano.blogspot.com/2019/04/from-htdp-to-racket-isbn-extraction-in.html It might be full of inaccuracies or even errors. So comments, fixes, or suggestions are welcomed. -- 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.