make a set of conditions without the parameters

• To: mathgroup at smc.vnet.net
• Subject: [mg57936] make a set of conditions without the parameters
• From: Guy Israeli <guyi1 at netvision.net.il>
• Date: Mon, 13 Jun 2005 05:50:53 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

I have a big list made out of smaller lists. I want to filter out specific
smaller lists, for instance those who have 1 in the first place and 3 in the
7th place.

I know what item cannot be in what place for the condition described above
but the only thing i could do is to do those rules using string like this:

t2 = {{0, 0, 0, {3}, 0, {4}, 0, 0, 0}, {0, {7}, {3}, 0, 0, 0, {1}, {4}, 0},
{{4},
0, 0, 0, {7}, 0, 0, 0, {6}}, {0, {9}, {5}, {4}, 0, {6}, 0, 0, 0}, {{8}, 0,
0, 0, {9}, 0, 0, 0, {3}}, {0, {4}, {6}, {8}, 0, {1}, 0, 0, 0}, {{6}, 0,
0, 0, 0, 0, 0, 0, {5}}, {0, {2}, {7}, 0, 0, 0, {3}, {8}, 0}, {0, 0,
0, {5}, 0, {7}, 0, 0, 0}};
rulesperline = Table[MapIndexed[ToString["#[["] <> ToString[#1] <>
ToString["]]!="] <> ToString[#2] &, (Part[#, i] & /@ Partition[Flatten[t2],
9] ) // Flatten], {i, 1, 9}];

newrules = Fold[(#1 /. ToString["#[[0]]!={"] <> ToString[#2] <>
ToString["}"] -> X) &,
rulesperline, Range[9]]

which will result in

{{X, X, #[[4]]!={3}, X, #[[8]]!={5}, X, #[[6]]!={7}, X, X}, {X, #[[7]]!={2},
X, #[[9]]!={4}, X, #[[4]]!={6}, X, #[[2]]!={8}, X}, {X, #[[3]]!={2},
X, #[[5]]!={4}, X, #[[6]]!={6}, X, #[[7]]!={8}, X}, {#[[3]]!={1}, X,
X, #[[4]]!={4}, X, #[[8]]!={6}, X, X, #[[5]]!={9}}, {X, X, #[[7]]!={3},
X, #[[9]]!={5}, X, X, X, X}, {#[[4]]!={1}, X, X, #[[6]]!={4},
X, #[[1]]!={6}, X, X, #[[7]]!={9}}, {X, #[[1]]!={2}, X, X, X, X,
X, #[[3]]!={8}, X}, {X, #[[4]]!={2}, X, X, X, X, X, #[[8]]!={8}, X}, {X,
X, #[[6]]!={3}, X, #[[3]]!={5}, X, #[[5]]!={7}, X, X}}

and then to cancel  the underlines

newrulesfull = Select[#, # != "X" &] & /@ newrules

{{#[[4]]!={3}, #[[8]]!={5}, #[[6]]!={7}}, {#[[7]]!={2}, #[[9]]!={4}, \
#[[4]]!={6}, #[[2]]!={8}}, {#[[3]]!={2}, #[[5]]!={4}, #[[6]]!={6}, \
#[[7]]!={8}}, {#[[3]]!={1}, #[[4]]!={4}, #[[8]]!={6}, #[[5]]!={9}}, \
{#[[7]]!={3}, #[[9]]!={5}}, {#[[4]]!={1}, #[[6]]!={4}, #[[1]]!={6}, \
#[[7]]!={9}}, {#[[1]]!={2}, #[[3]]!={8}}, {#[[4]]!={2}, #[[8]]!={8}}, \
{#[[6]]!={3}, #[[3]]!={5}, #[[5]]!={7}}}

The X here is just to mark that it is unimportnat.

however, each element is a string here. and now starts my problem

I would want to do Select[somelist, And[newrulesfull [[1]]]&] meaning it
will give the elements in somelist that match the all of the conditions in
rulesperline[[1]]. But since it is a string it doesn't do much, and
everytime I do ToExpression it gives me a lot of errors because it doesn't
know what #[[4]] or some other number is.

How can I make a list of rules like that so that I can use Select on those
conditions?

I'm sorry if my explanation was extremely confusing, I will try to clearify
it if parts were messy.

Thank you very very very very very very much

Guy.

```

• Prev by Date: Re: Portable Notebooks and Filenames[]
• Next by Date: Re: Re: Attempt to generalize a constant
• Previous by thread: Re: Write/WriteString -- writing delimited txt to a stream?
• Next by thread: Re: make a set of conditions without the parameters