-1
$\begingroup$

I have a list,

param2 = {
 {-qlim, -qlim},
 {-qlim, qlim},
 {qlim, -qlim},
 {qlim, qlim}
};

and want to get combination of them with,

Flatten[Table[{param2[[i]], param2[[j]]}, {i, 4}, {j, 4}], 2]

But this gives me list which includes sets that have item twice. I want to get

{1,2},{1,3},{1,4},{2,3},{2,4},{3,4}
$\endgroup$
6
  • 1
    $\begingroup$ What's the value of qlim? $\endgroup$
    – corey979
    Commented Jan 1, 2017 at 22:53
  • $\begingroup$ it is a scalar value like 1 or 3 $\endgroup$
    – freezer
    Commented Jan 1, 2017 at 22:54
  • $\begingroup$ That's not the answer to my question. I still don't know what do you want to achieve with your code, but the desired output can be obtained with Flatten[Table[{i, j}, {i, 1, 4}, {j, i + 1, 4}], 1]. $\endgroup$
    – corey979
    Commented Jan 1, 2017 at 22:55
  • $\begingroup$ Actually ı have written the index inside the list not the actual output. I didn't know that we can use one index inside other. I will try it tomorrow. Thank you. $\endgroup$
    – freezer
    Commented Jan 1, 2017 at 23:07
  • $\begingroup$ See also: mathematica.stackexchange.com/q/86138/121 $\endgroup$
    – Mr.Wizard
    Commented Jan 1, 2017 at 23:16

1 Answer 1

0
$\begingroup$
Subsets[param2, {2}]

{{{-qlim, -qlim}, {-qlim, qlim}},
{{-qlim, -qlim}, {qlim, -qlim}},
{{-qlim, -qlim}, {qlim, qlim}},
{{-qlim, qlim}, {qlim, -qlim}},
{{-qlim, qlim}, {qlim, qlim}},
{{qlim, -qlim}, {qlim, qlim}}}

$\endgroup$
7
  • $\begingroup$ Thanks that's what I wanted. What if ı just wanted this point to draw rectangle with these points are corner. $\endgroup$
    – freezer
    Commented Jan 1, 2017 at 23:12
  • $\begingroup$ @freezer, something like Graphics[{Hue@RandomReal[], Rectangle @@ #}] & /@ (Subsets[ param2, {2}] /. qlim -> 1)? $\endgroup$
    – kglr
    Commented Jan 1, 2017 at 23:23
  • $\begingroup$ nope @kglr. I think this is not what I asked. I want to get this list {{{-3, -3}, {3, -3}}, {{3, -3}, {3, 3}}, {{3, 3}, {-3, 3}}, {{-3, 3}, {-3, -3}}} as corners of ractangles automatically? Is this possible? $\endgroup$
    – freezer
    Commented Jan 2, 2017 at 23:28
  • $\begingroup$ @freezer, Rectangle @@@ {{{-3, -3}, {3, -3}}, {{3, -3}, {3, 3}}, {{3, 3}, {-3, 3}}, {{-3, 3}, {-3, -3}}} gives {Rectangle[{-3, -3}, {3, -3}], Rectangle[{3, -3}, {3, 3}], Rectangle[{3, 3}, {-3, 3}], Rectangle[{-3, 3}, {-3, -3}]}. Note that some of these are simply lines (degenerate rectangles). $\endgroup$
    – kglr
    Commented Jan 2, 2017 at 23:40
  • $\begingroup$ :) I think I couldn't be clear as I need. I need to get that list from possible values of coordinates. Don't want to write manually. $\endgroup$
    – freezer
    Commented Jan 3, 2017 at 0:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.