For Programmers: Free Programming Magazines  


Home > Archive > Mathematica > November 2007 > Re: / functional outer product?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: / functional outer product?
DrMajorBob

2007-11-30, 8:21 am

Transpose@Outer[#1@#2 &, {f, g}, {a, b, c}]

{{f[a], g[a]}, {f[b], g[b]}, {f[c], g[c]}}

Composition[Through, {f, g}] /@ {a, b, c}

{{f[a], g[a]}, {f[b], g[b]}, {f[c], g[c]}}

Through /@ {f, g} /@ {a, b, c}

{{f[a], g[a]}, {f[b], g[b]}, {f[c], g[c]}}

Bobby

On Thu, 29 Nov 2007 05:36:04 -0600, Mitch Murphy <mitch@lemma.ca> wrote:

>
> greetings,
>
> is there a simpler way to express
>
> {f@#,g@#}& /@ {a,b,c}
>
> -> {{f[a],g[a]},{f[b],g[b]},{f[c],g[c]}}
>
> ie. is there some mathematica function ??? such that
>
> {f,g} ??? {a,b,c}
>
> -> {{f[a],g[a]},{f[b],g[b]},{f[c],g[c]}}
>
> you might be asking what's so difficult about the "@#,@#,... & /@"
> syntax, but what about when you don't have two functions f,g but 8-10
> functions... the syntax gets ugly fast and hard to read.
>
> note that
>
> Outer[{f, g}, {a, b, c}]
>
> -> {{f, g}[a], {f, g}[b], {f, g}[c]}
>
> doesn't work, neither does
>
> Outer[Apply, {f, g}, {a, b, c}]
>
> ->{{a, b, c},{a, b, c}}
>
>
> thanks,
> Mitch
>
>
>
>




--
DrMajorBob@bigfoot.com

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com