Re: Two questions related to Arrays
- To: mathgroup at smc.vnet.net
- Subject: [mg113327] Re: Two questions related to Arrays
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Sat, 23 Oct 2010 07:08:31 -0400 (EDT)
On Oct 22, 2010, at 1:35 AM, Sam Takoy wrote:
> Hi,
>
> First, why doesn't the following return the first two elements of the
> outer list:
>
>
> Cases[{{{1}, {2}}, {3, 4}, {{5}, 6}}, _Array]
Array is not a head, use ArrayQ yo find arrays.
Cases[{{{1}, {2}}, {3, 4}, {{5}, 6}}, _?ArrayQ]
> Second, I'm looking for help writing a function
>
> f[t__]:=
>
> that returns Outer[Times, u] where u only includes the input variables
> that are Arrays.
Using the prior idea:
f[t__]:=Outer[Times,Sequence@@Cases[t,_?ArrayQ]]
Regards,
Sseziwa