Re: newbie list question
- To: mathgroup at smc.vnet.net
- Subject: [mg114997] Re: newbie list question
- From: Vince Virgilio <blueschi at gmail.com>
- Date: Tue, 28 Dec 2010 06:47:59 -0500 (EST)
- Reply-to: comp.soft-sys.math.mathematica at googlegroups.com
listA = {4, 5, 8, 2, 6, 4}; listB = {8, 4, 2}; listC = {8, 4, 22, 2}; Flatten@Position[listA, #, 1, 1] & /@ listB {{3}, {1}, {4}} Flatten@Position[listA, #, 1, 1] & /@ listC {{3}, {1}, {}, {4}} The extra sets of braces allows for "misses", as in listC. I thought if order of the positions was important, then spacing would be as well. If unnecessary, move Flatten to the end of the solution to eliminate all nesting of positions, i.e. ... // Flatten. This might be too slow for large lists. There's probably a faster way than mapping Position. Vince Virgilio