[Date Index]
[Thread Index]
[Author Index]
Re: Working with Lists
*To*: mathgroup at smc.vnet.net
*Subject*: [mg104369] Re: [mg104327] Working with Lists
*From*: Bob Hanlon <hanlonr at cox.net>
*Date*: Thu, 29 Oct 2009 02:57:56 -0500 (EST)
*Reply-to*: hanlonr at cox.net
f = Array[a, {4, 2}]
{{a[1, 1], a[1, 2]}, {a[2, 1],
a[2, 2]}, {a[3, 1], a[3, 2]},
{a[4, 1], a[4, 2]}}
c1 = f[[All, 1]]
{a[1, 1], a[2, 1], a[3, 1], a[4, 1]}
c2 = f[[All, 2]]
{a[1, 2], a[2, 2], a[3, 2], a[4, 2]}
f == Thread[{c1, c2}]
True
f == Transpose[{c1, c2}]
True
f2 = {{0, 1}, {7, 1}, {12, 2}};
rd = {1 -> 1/4, 2 -> 1/2};
f2 /. {x_, y_} :> {x, y /. rd}
{{0, 1/4}, {7, 1/4}, {12, 1/2}}
{#[[1]], #[[2]] /. rd} & /@ f2
{{0, 1/4}, {7, 1/4}, {12, 1/2}}
Thread[{f2[[All, 1]], f2[[All, 2]] /. rd}]
{{0, 1/4}, {7, 1/4}, {12, 1/2}}
Read the documentation:
http://reference.wolfram.com/mathematica/tutorial/VectorsAndMatrices.html
http : // reference.wolfram.com/mathematica/ref/List.html
http : // reference.wolfram.com/mathematica/ref/Sequence.html
http : // reference.wolfram.com/mathematica/ref/VectorQ.html
http://reference.wolfram.com/mathematica/ref/Array.html
http://reference.wolfram.com/mathematica/ref/MatrixQ.html
http://reference.wolfram.com/mathematica/ref/Table.html
http://reference.wolfram.com/mathematica/ref/Grid.html
http://reference.wolfram.com/mathematica/tutorial/ListsOverview.html
Bob Hanlon
---- BenT <brtubb at pdmusic.org> wrote:
=============
I have several practical problems which I need to solve, and
understand, preferable in a generic matter well, before needing to
apply them specifically pertaining to:
using a "generic" example:
f={{1,2,},{3,4,},{5,6},{7,8}}
NOTE: the use of 1 thru 8 for the values is purely arbitrary so please
to do not apply any "simplifications" based on their present values.
I know have to obtain the sum of all of the elements in each of the
lists by using
Apply[Plus,f]
and from it, I can use the Part function or "[[]]" method of obtaining
each result as needed.
asum=Apply[Plus,f][[1]]
bsum=Apply[Plus,f][[2]]
What I further need are methods to:
(1) obtain separate lists, call them a and b which contain just the
1st and 2nd elements of each sublist respectively
(2) then after further, if eny modification of either list's data (a
copletely separate issue), I need to know the method of how to merge
them, and replace the original data.
I know how to apply Rule's to transform data on a list of single
elements, but not for "larger" lists.
Consider this code:
f={{0,1},{7,1},{12,2}}
rd={1->1/4,2=1/2}
How can I apply the rd "rule" (or any Rule) to just the second
elements' 2nd values in the f list? And more importantly how are such
things done generically?
And someone please define distinct differences between:
(1) list
(2) sequence
(2) vector
(2) array
(3) matrix/table
I'm using Mathemata Version 7, but am only a "hobbies" at it. Music is
my primary interest.
--- Benjamin Tubb
Prev by Date:
**Re: presentations**
Next by Date:
**Opportunities and Player Pro**
Previous by thread:
**Re: Working with Lists**
Next by thread:
**Re: Working with Lists**
| |