# How to calculate possible combinations of elements of a vector in GAUSS

User ForumHow to calculate possible combinations of elements of a vector in GAUSS
aptech Staff asked 3 years ago

Is there a way in GAUSS to calculate all the possible combinations of a list of length N take K at a time?

aptech Staff answered 3 years ago

The GAUSS function combinate will return the indices of all possible combinations of a vector of length N taken K at a time. Each row of this function will contain the indices of a different combination. For example:

```x = { 0.35, 1.2, 0.9, 4.7 };

//calculate the indices of all combinations
cmb = combinate(4, 2);
print cmb;
```

will return the indices:

```1        2
1        3
1        4
2        3
2        4
3        4
```

Using these indices you can print out each of the combinations like this:

```//loop through and print all combinations
for i(1, rows(cmb), 1);
print x[cmb[i,.]];
endfor;
```

which will return the following output:

```0.35
1.20

0.35
0.90

0.35
4.70

1.20
0.90

1.20
4.70

0.90
4.70
```

• ### Aptech Systems, Inc. Worldwide Headquarters

Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286

Phone: 360.886.7100
FAX: 360.886.8922

• ### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

• ### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

• ### Have a Specific Question?

Get a real answer from a real person

• Need Support?
• ### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

• ### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!