what happened to 'ev' ?



On Fri, Aug 28, 2009 at 4:34 PM, Leo Butler <l.butler at ed.ac.uk> wrote:

> On Fri, 28 Aug 2009, Stavros Macrakis wrote:
>
> < The core problem here is that the 'option' argument of s_list uses the
> < literal free variable 'x' in the condition.
> <
> < The 'lambda([x],...)' construction used in sublist has far cleaner
> semantics
> < that the arbitrary free variable 'x' being used to represent the
> argument,
> < so I would strongly recommend sticking to sublist.
> <
> < If it is so important to save a few keystrokes at the cost of anomalous
> < semantics, the better way to define s_list is as a macro (using ::=).
>  But I
> < don't recommend that.
>
> As a macro:
>
> (%i2) slist(l,o,[varname]) ::= buildq([l,o,v:if varname=[] then 'x else
> part(varname,1)], sublist(l,lambda([v],is(o))))$
> (%i3) slist([1,2,4,6],x<4);
> (%o3) [1,2]
> (%i4) slist([1,2,4,6],t<4);
> (%o4) [1,2,4,6]
> (%i5) slist([1,2,4,6],t<4,t);
> (%o5) [1,2]
> (%i6) slist([1,2,4,6],t<4 and t>1,t);
> (%o6) [2]
>
> I'm curious to know why you don't recommmend this.
>

I don't recommend it because the meaning of 'x' is not clear from the
context and because 'x' is arbitrary: what if you want to know whether the
first element is equal to some x in the environment?

It's much better with a varname argument, though I still prefer the explicit
lambda.  If the symbol "lambda" is too long, define say "f" to be a macro
for lambda....

             -s