MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Short, simple - Why doesn't it work as a function


wooks wrote:
> {#, a} & /@ {a, b, c}
> 
> gives {{a, a}, {b, a}, {c, a}} which is what i want.
> 
> why[x_List] := {#, a} & /@ x;
> why[{a, b, c}]
> 
> gives.
> 
> {{a, a}, {{b, a}, {{c, a}, {}}}}
> 
> not what I want.
> 
> I've checked the FullForms and they are different - why??
> 
Works fine on my system. I would advise to try again with a fresh kernel.

In[1]:=
({#1, a} & ) /@ {a, b, c}

Out[1]=
{{a, a}, {b, a}, {c, a}}

In[2]:=
FullForm[%]

Out[2]//FullForm=
FullForm[{{a, a}, {b, a}, {c, a}}]

In[3]:=
why[x_List] := ({#1, a} & ) /@ x;
why[{a, b, c}]

Out[4]=
{{a, a}, {b, a}, {c, a}}

In[5]:=
FullForm[%]

Out[5]//FullForm=
FullForm[{{a, a}, {b, a}, {c, a}}]

Regards,
Jean-Marc


  • Prev by Date: Re: Strange empty set of solutions
  • Next by Date: two format questions
  • Previous by thread: Re: Short, simple - Why doesn't it work as a function
  • Next by thread: Strange empty set of solutions