[Date Index]
[Thread Index]
[Author Index]
Re: slot argument weirdness
*To*: mathgroup at smc.vnet.net
*Subject*: [mg83929] Re: slot argument weirdness
*From*: Tom Burton <news at brahea.com>
*Date*: Wed, 5 Dec 2007 07:02:13 -0500 (EST)
Considering that all the examples of slots in online help (Slot) show
slots inside of pure functions, where is the weirdness: in the slots,
or in your attempt to use them outside their native habitat?
You're so close :-) How about?
m={{#1,#2},{#2,#1}}&;
Apply[m, v]
Simple pure functions are fine, but complex ones can be hard to read.
How about instead a regular function,
m=Function[{u,v},{{u,v},{v,u}}]
or a rule?
r={u_,v_}:>{{u,v},{v,u}};
v/.r
Tom
When responding, please replace news with my first initial and full
last name, as one word.
Tom Burton
> 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};
>
> ... 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 ...
Prev by Date:
**Re: File reading and writing within for loop**
Next by Date:
**Re: slot argument weirdness**
Previous by thread:
**slot argument weirdness**
Next by thread:
**Re: slot argument weirdness**
| |