Re: Holding Arguments in a Second Argument List
- To: mathgroup at smc.vnet.net
- Subject: [mg32278] Re: Holding Arguments in a Second Argument List
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Wed, 9 Jan 2002 23:37:57 -0500 (EST)
- References: <a1gv0f$n6c$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
David,
> Can anyone tell me how to get rid of the Return wrapper?
How about
foo[mathgroup_] =
Function[mat,
If[Not[mathgroup === great], Throw[$Failed]]//Catch,
{HoldFirst}
]
foo[x][mat]
$Failed
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"David Park" <djmp at earthlink.net> wrote in message
news:a1gv0f$n6c$1 at smc.vnet.net...
> Dear MathGroup,
>
> I have a series of procedures which manipulate a matrix. I like to define
> them in this fashion.
>
> function[args___][matrix_] := ... because then I can write lines like
>
> matrix // function[args...] etc.
>
> But I have to define the function so that matrix is held, and I don't want
> to write Unevaluated with every use. But Attributes = {HoldFirst} only
> applies to the first argument list. Is there a direct way to define the
> attributes of a second argument list?
>
> In any case, I write the routines this way.
>
> function[args___]:=
> Function[matrix,
> Module[{}, code],
> {HoldFirst}]
>
> and that works. The code usually changes the matrix and I display it
> separately. But sometimes the operation will fail and then I would like
>
> function[args...][matrix]
>
> to return $Failed. But I am unable to do that. The best I seem to be able
to
> do is return Return[$Failed].
>
> Here is a sample routine which just tries to return $Failed.
>
> foo[mathgroup_] :=
> Function[mat,
> Module[{},
> If[Not[mathgroup === great], Return[$Failed]]],
> {HoldFirst}]
>
> foo[x][mat]
> Return[$Failed]
>
> Can anyone tell me how to get rid of the Return wrapper?
>
> Thanks
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
>