[racket] match in Advanced Student?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Aug 17 19:50:11 EDT 2011

This is a fine program:

#lang htdp/isl
(require racket/match)
(define (nth-square n)
  (match n
    [1 1]
    [else (+ (* n 2) -1 (nth-square (- n 1)))]))

(map nth-square (build-list 10 add1))

I guess you mean something more general than that, but I can't tell
what (and probably you've already told me and I've already agreed with
you but this message isn't pulling on the right memory strings, I'm
sorry to say).


On Wed, Aug 17, 2011 at 6:05 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> This strategy certainly doesn't work with require, as I've reported
> earlier, because you have to *know* and *enumerate* (and then
> maintain) all the require sub-forms, which are their own macros.
> Ditto for provide, and some other such constructs.  So you can't just
> tell your students to require one thing and be done with it.  I don't
> know whether match is done this way but in general this strategy
> doesn't work for bringing in the constructs you want.
> I think the student require form is also restricted to not let you be
> able to do such things, but I may be remembering incorrectly.
> Shriram
> On Wed, Aug 17, 2011 at 6:02 PM, Robby Findler
> <robby at eecs.northwestern.edu> wrote:
>> Could you just require match into bsl/isl?
>> Robby
>> On Wednesday, August 17, 2011, Prabhakar Ragde <plragde at uwaterloo.ca> wrote:
>>> On 8/17/11 10:30 AM, Shriram Krishnamurthi wrote:
>>>> My experience last year was that the restrictions on some of these
>>>> sub-forms were arbitrary and not helpful. It also makes it harder for
>>>> students because if they click on the "wrong" documentation, they
>>>> don't understand why the thing that the docs say should work doesn't.
>>> Well, I certainly didn't. The Advanced Student documentation doesn't
>>> really explain `match', so one has to go to the Guide or Reference anyway
>>> (e.g. for quasipatterns). It takes some careful peering at the grammar of
>>> Advanced Student to notice that ASL `match' is restricted, and to figure out
>>> what is permissible.
>>> I would like to use `and', `or', and `?' patterns, at least. But to do so
>>> I have to take the students into Advanced Student earlier than I want (just
>>> after functional abstraction) and forbid them to use all the `!' functions
>>> and I/O. However, if I'm only going to get a restricted version of `match'
>>> by doing that, I might as well take them into #lang racket.
>>> Okay, maybe I won't go to that extreme yet. Let me see how far I can get
>>> without full `match'. --PR
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.