Re: slot argument weirdness

• To: mathgroup at smc.vnet.net
• Subject: [mg83934] Re: slot argument weirdness
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Wed, 5 Dec 2007 07:04:51 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <fj37b2\$hok\$1@smc.vnet.net>

```Jerry wrote:
> I have to produce some bulky matrices which are described by
> two parameters and it seems the easiest way to produce them
> is as follows (I took out all the complexity and just left
> in the slots to illustrate my problem). v is the parameter
> array.
>
> v = {2, 5};
> myMatrix=Apply[{{#1, #2}, {#2, #1}} &, v]
>
> giving     {{2, 5}, {5, 2}}    and all is well.
>
> But since the actual form in the first argument in Apply is
> really a large messy thing, I thought I'd produce it just
> once in the notebook and represent it with:
>
> m = {{#1, #2}, {#2, #1}};
>
> But geez, this doesn't work at all:

This is normal since you have defined is an incomplete pure function. In
other words, Slot must always be accompanied by & to form a syntacticly
correct expression.

> MyMatrix2= Apply[m &, v]
>
> gives      {{#1, #2}, {#2, #1}}
>
> I've tried a lot of things to make this work but have failed
> completely. If someone can tell me that there is absolutely
> no representation of the slot configuration that will do
> what I want, then I can quit trying. Or is there? Thanks for
> any info.

v = {2, 5};
m = {{#1, #2}, {#2, #1}} &;
Apply[m, v]
m @@ v

Regards,
--
Jean-Marc

```

• Prev by Date: Re: slot argument weirdness
• Next by Date: Re: Partition a list into sublists of unequal size
• Previous by thread: Re: slot argument weirdness
• Next by thread: Re: slot argument weirdness