Re: extract from list and keep track

• To: mathgroup at smc.vnet.net
• Subject: [mg62182] Re: extract from list and keep track
• From: Roger Bagula <rlbagulatftn at yahoo.com>
• Date: Sun, 13 Nov 2005 21:16:19 -0500 (EST)
• References: <dl4ah1\$j48\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Here's a two liner that is a little easier to understand:
data = {3, 7, 9, 21, 43, 57, 63, 71, 75, 99}
a = Delete[Union[Table[If[Mod[data[[n]], 8] ==
1 || Mod[data[[n]], 8] == 7, {n, data[[n]]}, {}], {n, 1,
Length[data]}]], 1]
"Union" sorts the extra  {} to the front and "Delete" gets ride of it.
|| means "or"
Using an "If" like this makes the clause more like a regular programing
or mathematical statement.
Andrea wrote:
> I'm trying to write a program for the following. Seems simple, but I'm
> unable to to do it:
>
> I have a list of increasing odd numbers. I want to create a table that
> indicates which numbers in this list are 1(mod 8) and 7(mod 8) and what
> position in the list these numbers have.
> Then I would like to have them removed form the list to get a new (reduced)
> list.
>
>
> Example: 3, 7, 9, 21, 43, 57, 63, 71, 75, 99.   I want to form this a Table:
>
> 2      7
> 3      9
> 6    57
> 7    63
> 8    71
>
> 7 is 7(mod 8) and is the 2nd member in the list, 9 is 1(mod 8) and is the
> 3rd member in the list, etc.
>
> The next list would become, having removed the ones in the table:
>
> 3, 21, 43, 75, 99
>
> And I would be using some other congruence criteria. Etc.
>
> Thanks,
> Andrea
>

```

• Prev by Date: Re: Types in Mathematica
• Next by Date: Re: 5.2 on suse 10.0 error
• Previous by thread: Re: extract from list and keep track
• Next by thread: Re: Accessing unevaluated input line