# How to list all solutions appearing in range [duplicate]

A function h that I've written (it uses Reduce) outputs a list of integer solutions of the form e.g.

(a0 = 1 && a1 = 2 && a2 = 3) || (a0 = 2 && a1 = 3 && a2 = 4) || ... .

Some of the solutions however are of the form e.g. (a2 \[Element] Integers && a0 = 1 && a1 = 2 && -6 <= a2 <= 8). I'd like to seperate the solutions in the latter form into the former form, i.e. I would like to have the latter ones appearing as

(a0 = 1 && a1 = 2 && a2 = -6) || (a0 = 1 && a1 = 2 && a2 = -5) || ... .

The reason I ask is because I am exporting the wholle list of solutions into a .csv file as follows:

solns = Table[h[b, a0, a1, 0, 12], 1]]

Export["solns.csv", solns]

When solutions are of the former form, the .csv output is manageable for me, but with the latter form it is too messy. Does anyone know a way to fix this?

Many thanks.

• Can you put a short example of the output you wish to modify in copy-pastable form? Sep 16, 2021 at 14:50
• Hi Bill, here's an excerpt: (a0 == 26 && a1 == -15 && a2 == 49) || (a0 == 26 && a1 == -15 && a2 == 50) || (a0 == 26 && a1 == -15 && a2 == 51) || (a2 [Element] Integers && a0 == 27 && a1 == -15 && 39 <= a2 <= 50) || (a0 == 28 && a1 == -15 && a2 == 35) || Sep 16, 2021 at 14:56
• sorry, maybe some of the symbols have changed slightly, e.g. I think the equals signs should just be = Sep 16, 2021 at 15:02

Say the output you are getting looks like:

out = (a0 == 1 && a1 == 2 && a2 == 3) || (a0 == 2 && a1 == 3 && a2 == 4) ||
(a2 \[Element] Integers && a0 == 1 && a1 == 2 && -6 <= a2 <= 8) || (a1 \[Element] Integers && a0 == 1 && a1 == 2 && -6 <= a2 <= 8)


Then you can remove the extra "Element" terms by:

DeleteCases[out /. Element -> Nothing, Nothing, 2]

(a0 == 1 && a1 == 2 && a2 == 3) || (a0 == 2 && a1 == 3 && a2 == 4) ||
(a0 == 1 && a1 == 2 && -6 <= a2 <= 8) || (a0 == 1 && a1 == 2 && -6 <= a2 <= 8)

• Thanks for the answer, but would it be possible to list out each of the e.g. 15 solutions from (a0 == 1 && a1 == 2 && -6 <= a2 <= 8) as solutions of the form (a0 == ... && a1 == ... && a2 == ...) ? Sep 16, 2021 at 15:15
• I tried the solnsModified /. Or -> List method but it didn't seem to list them out. The things that changed were that the solutions no longer had brackets, and were delimited by commas instead of double vertical lines. Sep 16, 2021 at 15:31
• Can you be clearer about what actual output you desire? I had thought the above was the task (to remove the "element of" and to make them a list) but apprently you are looking for something more. For instance, for the term (a0 == 1 && a1 == 2 && 6 <= a2 <= 8) what would you want the output to look like? Sep 16, 2021 at 17:30
• Thank you for the help everyone - setting SetSystemOptions[{"ReduceOptions" -> "DiscreteSolutionBound" -> 300}] as in the linked question solved my problem! Sep 17, 2021 at 8:26