declare and remove inside block



On 1/7/10, Edwin Woollett <woollett at charter.net> wrote:

>    mscalar ([v]) :=
>     block ( [jj,_pp%],
>      for jj thru length (v) do (
>        _pp% : v[jj],
> /* none of these three methods work: */
>     /* declare (_pp%,scalar), */
>    /*  ev (declare (_pp%,scalar)), */
>        apply ( 'lambda([z], declare (z,scalar)  ), [_pp%] ),
>        scalarL : cons (_pp%, scalarL) ),
>        display (scalarL) )$

Well, here you want apply('declare, [_pp%, 'scalar]) .

>    unscalar ([v]) :=
>     block ([jj,_np%,_pp% ],
>        for jj thru length (v) do (
>          _pp% : v[jj],
>          if not lfreeof (scalarL, _pp%) then (
>           /* doesn't work */
>             remove (_pp%,scalar),
>            _np% : pos (scalarL,_pp%),
>            scalarL : remL1 (scalarL, _np% ) ) ),
>        display (scalarL) )$

 ... and here you want apply('remove, [_pp%, scalar]) .

Both declare and remove quote their arguments.
I see that's mentioned in the documentation for declare
but not remove; I'll throw a line into the documentation for that.

Hope this helps

Robert Dodier