MathGroup Archive 1999

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

Search the Archive

Re: Attribute : Listable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20496] Re: [mg20391] Attribute : Listable
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Wed, 27 Oct 1999 02:04:57 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

First a point of logic: the fact that a function is threaded over lists when
it has the attribute "Listable" does not imply that it isn't threaded over
lists when it doesn't have this attribute. More precisely, some functions do
this as a consequence of some of the way they are defined internally and not
as a result of adding an additional attribute which can be removed by the
user. This is easy to see in the case of N.  Here is the information on N
from the Mathematica book:

"N converts each successive argument of any function it encounters to
numerical form, unless the head of the function has an attribute such as
NHoldAll." 

Thus:

In[8]:=
N[f[2, 3]]

Out[8]=
f[2., 3.]

This is true for any f, including List. Thus in this case the "listability"
is a consequence of a much more general property. Unlike the case of
functions having the attribute "Listable" you can't remove this property
from N. 

The case of ComplexExpand and complex Expand  seems rather harder to
explain. Both of these functions do not thread over arbitrary heads (but
ExpandAll does):

In[1]:=
Expand[g[(1 + x)^3, (1 + x)^2]]
Out[1]=
         3         2
g[(1 + x) , (1 + x) ]

but they thread over some, e.g. Plus, Times and List. This latter property
is needed in order so that entries of matrices can be expanded (for
example). Again, listability is a consequence of the internal code of Expand
and can't be removed.

 
-- 


> From: CORNIL Jack Michel <jmcornil at club-internet.fr>
To: mathgroup at smc.vnet.net
> Date: Tue, 26 Oct 1999 00:32:48 -0400
> To: mathgroup at smc.vnet.net
> Subject: [mg20496] [mg20391] Attribute : Listable
> 
> Hello,
> 
> I have a problem with the attribute "Listable".
> 
> It is said in documentation that a function is threaded over lists if
> one of its attributes is "Listable".
> 
> Neither the function N nor the function ComplexExpand has "Listable"
> among its attributes and however both of them are mapped on lists of
> numbers.
> 
> Can someone explain me ?
> 
> 
> Thanks in advance,
> 
> J.M. CORNIL
> 
> 



  • Prev by Date: Re: A simple question? Please help
  • Next by Date: Re: StylePrint problem
  • Previous by thread: Attribute : Listable
  • Next by thread: Preventing NotebookWrite From Wrapping