[Date Index]
[Thread Index]
[Author Index]
Re: Ignorance
*To*: MATHGROUP at yoda.ncsa.uiuc.edu
*Subject*: Re: Ignorance
*From*: don at kinghorn.chem.WSU.EDU (Don Kinghorn)
*Date*: Sat, 27 Oct 90 13:40:37 PDT
Begin received message:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dear mathgroupers,
I have a function defined like this:
MatrixB[x_List]:=Block[{tt={x},z,i,n,zoo},
n=x[[1]]/2;
zoo=x;
z=Table[0,{i,Length[x]}];z[[2]]++;
For[i=1,i<=n-x[[2]],i++,tt=AppendTo[tt,zoo=zoo+z]];tt
]
It is probably a bad example of Mathematica programming, but anyway it
does what I want: taking as input a vector it builds an appropriate matrix.
Now it would be interesting if it accepted as input a list of vectors,
giving as result the matrix of the matrices resulting from the analisys of
each element of the input. How must I modified my code? Thank you in
advance for your help.
Riccardo Rigon
(an absolute beginner)
RIGON at iveuncc.bitnet
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
It looks to me like your code could be greatly simplified as follows;
MatrixB[x_List]:=Table[x/. x[[2]]->x[[2]]+i, {i,0,Floor[ x[[1]]/2 - x[[2]] ]} ]
at least I think this is what you want.
In answer to your question, you can apply functions to lists by using Map.
For example;
Map[ MatrixB, { list1,list2,list3} ]
should do what you want.
I hope this helps. :-)
Don Kinghorn
Washing State University
Chemical Physics Dept.
don at kinghorn.chem.wsu.edu
Prev by Date:
**Re: math coprocessors**
Next by Date:
**Mathematica on a PC**
Previous by thread:
**Re: Logical expressions in Mathematica**
Next by thread:
**Mathematica on a PC**
| |