Re: What makes things Listable?

*To*: mathgroup at smc.vnet.net*Subject*: [mg26325] Re: [mg26302] What makes things Listable?*From*: "Carl K. Woll" <carlw at u.washington.edu>*Date*: Tue, 12 Dec 2000 02:54:41 -0500 (EST)*References*: <200012100520.AAA07003@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Chris, The old way (before version 4.0) to apply Value to a list the way you want to do is to map a pure function as in Value@@#&/@data In version 4.0 they created a shortcut, so simply Value@@@data will give you the result you're looking for. One other note. Your subject line asks what makes things listable. Listable is an attribute, which you can set through the SetAttributes command, as in SetAttributes[Value, {Listable}] In your example, though, giving Value the Listable attribute would not help matters. Carl Woll Physics Dept U of Washington ----- Original Message ----- From: "Chris Johnson" <cjohnson at shell.faradic.net> To: mathgroup at smc.vnet.net Subject: [mg26325] [mg26302] What makes things Listable? > I'm using the "Finance Essentials" package and want to use the Value > command over a list of bonds. For those not familiar with the package, > there is a structure called Bonds which defines the coupon, maturity, > etc. for a bond. The Value command takes three arguements, Bond, > SettlementDate, YieldToMaturity and returns a price. > > Having vectors of Bonds, Dates, and Yields, I want to create a vector > of prices. My first guess was to try the following command: > Value[Transpose[{bondlist,datelist,yields}]] > > This returned the result > Value[{{bond[1],valdate[1],yield[1]},...}] > > My next step was to use Map[Value,Transpose[...]] which returned a list > like {Value[{bond,valdate,ytm}],...} where the parameters for Value are > surrounded by curly braces. Value wouldn't evaluate over parameters in > this form. > > The solution I found for now is to create my own fuction > > cjValueList[{x_,y_,z_}]:=Value[x,y,z] > > and then mapping cjValueList provides the table I seek. I have run into > this general problem of wanting to get rid of the outer level of curly > braces before, and wonder if there is a more general solution then this > hack redefinition of the function? > > Thanks, > Chris Johnson > >

**References**:**What makes things Listable?***From:*Chris Johnson <cjohnson@shell.faradic.net>