// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class Comb {
   public static void process(int[] b) {
      for (int j = 0; j < b.length; j++) {
         System.out.print(" " + b[j]);
      }
      System.out.println();
   }
   public static void allcomb(int[] a, int len, int[] b, int ix, int start) {
      if (ix < b.length) {
         for (int i = start; i < a.length; i++) {
            b[ix] = a[i];
            allcomb(a, len, b, ix + 1, i + 1);
         }
      } else {
         process(b);
      }
   }
   public static void allcomb(int[] a, int len) {
      int[] b = new int[len];
      allcomb(a, len, b, 0, 0);
   }
   public static void allcomb(int[] a) {
      for (int len = 1; len <= a.length; len++) {
         allcomb(a, len);
      }
   }
   public static void main(String[] args) {
      int[] a = { 1, 3, 5 };
      allcomb(a);
   }
}
