Original-Via: uk.ac.ox.prg; Mon, 4 Nov 91 13:52:20 GMT

Kent Karlsson asks:
| Which semantics did you use?

The following seemed sensible to me (Your first choice in each case):

For p+k patterns: (as in the report):
         case e0 of {p+k -> e; _ -> e'}
         = if e0 >= k then let {p = e0-k} in e else e'

For c*p patterns:
         case e0 of {c*p -> e; _ -> e'}
         = if e0 >= 0 && e0 `rem` c == 0
             then let {p = e0 `div` c} in e
             else e'

I think these would agree with Tony Davie's original proposal in the special
case of c*x+k patterns?

| Any syntactic restrictions on c or k (e.g. k >= 0, c >= 1)?

I think I had k>0, c>1, but I guess your limits are just as good.

|   Note, I'm not opposing anything here, I'm just asking!
|                       /kent k

And I'm not suggesting that Haskell has p+k and c*p patterns.
I implemented them so that I could play with the ideas involved.
I'm not particularly convinced either way whether they should
be adopted or not.


Reply via email to