Hi Barton,
> I'd prefer a solution that doesn't
> force you into defining a new rule for every situation.
How about if we solve this problem by making it easier
to define rules. I'd like to see that anyway, and I think
it's preferable to constructing a function which is sort
of like apply1 but not really. (We could rename apply1
while we're at it.)
In the examples you've given, it seems the key point is
to modify a rule for different circumstances.
Why not allow an expression like "(rule name) when (predicate)"
to represent an unnamed rule which is a restricted
version of <rule name>.
apply1 (expr, r1, r2 when integerp (n),
r3 when integerp (n) and n > 2);
We could of course make the predicate a separate argument,
but that necessitates inventing another function, and using
a word like "when" or "where" or "assuming" ties the predicate
to the rule it modifies in a stronger manner than separating
the two by a comma.
The "foo when bar" stuff doesn't exist, but I'm pretty sure
it would be straightforward to build it.
For what it's worth,
Robert Dodier