|
[Date Index]
[Thread Index]
[Author Index]
Re: List handling
- To: mathgroup at smc.vnet.net
- Subject: [mg15277] Re: List handling
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Thu, 31 Dec 1998 04:39:32 -0500
- References: <76ciqj$o51@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Jorge Zickermann wrote in message <76ciqj$o51 at smc.vnet.net>...
>...........
>Having obtained the positions of certain selected elements from ListB, I
>want to substitute the corresponding elements in ListA by the
>corresponding elements in ListC.
> ..........
Jorge:
listA = {1, 2, 3, 4};
listB = {3, 2 , 5, 1};
Flatten[Position[listB, _?(# > 2 &)]]
{1, 3}
listA [[%]] = listB[[%]];
listA
{3, 2, 5, 4}
If the lists might not be of the same lenght then we can use
listB = {3, 2 , 5, 1, 7};
Cases[Flatten[Position[listB, _?(# > 2 &)]], _?(# <= Length[listA] &)]
{1, 3}
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
Prev by Date:
RE: How to use HoldForm within Module
Next by Date:
stumping Integrate *correction*
Previous by thread:
RE: List handling
Next by thread:
Re: List handling
|