extracting elements from a list of lists
- To: mathgroup at smc.vnet.net
- Subject: [mg5811] extracting elements from a list of lists
- From: Olivier Georg <olivier.georg at studi.epfl.ch>
- Date: Wed, 22 Jan 1997 00:44:15 -0500
- Organization: EPF Lausanne
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
Suppose I have lists within a list, like:
myList = {{a,b}, {c,d}}
and I want to extract some element (let's say the d).
I can request:
myList[[2,2]].
Now suppose what I have the index of the element as
the list {2,2}. Then I can do:
Fold[Part, myList, {2,2}]
Is it correct to suppose that it will first return the
2nd sublist, and then extract the second element from it?
How efficient is it? This may be a crucial point
if I have long lists, I think. Then isn't there a
better way of doing this?
Olivier
--
-------------------------------------------------------------------
| Olivier Georg \__ e-mail: Olivier.Georg at studi.epfl.ch |
| Rte de Chailly 159 \__ home: http://diwww.epfl.ch/~ogeorg |
| 1814 La Tour-de-Peilz \__ tel: +41 21 944 15 42 |
------------------------------\__----------------------------------
| On ne peut pas tuer le temps \__ |
| Sans blesser un peu l'eternite \__ ________ __o |
| ( As if you could kill time ) \__ _____ _`\<,_ |
| ( without injuring eternity. ) \__ ___ (_)/ (_) |
| Henry David Thoreau \ |
-------------------------------------------------------------------