DOCOMB will evaluate <ob> for every combination of <n> elements from list <L>. Usage is similar to DOLIST and DOSUBS:
Input:
3: L list of objects
2: n number of elements to be taken each time
1: ob object to be evaluated
Output: ob evaluated for each of the COMB(s,n) combinations of n elements of L@ DOCOMB 230.5_Bytes # 1997h (48G)
\<<
ROT DUP SIZE 1 + 0
\-> ob L s DoC
\<<
{}
{ OVER 1 -
\-> t n
\<<
s 1 -
IF n
THEN FOR s n L s GET 1 \->LIST t + DoC EVAL NEXT
ELSE FOR s L s GET t LIST\-> DROP ob EVAL NEXT
END
\>>
} DUP 'DoC' STO EVAL
\>>
\>>examples:
{ 11 22 33 44 }
3
\<< 3 \->LIST \>>
DOCOMB
results in
{ 11 22 33 }
{ 11 22 44 }
{ 11 33 44 }
{ 22 33 44 }0
{ (0,3) (0,0) (4,0) (3,4) (4,3) }
2
\<< - ABS MAX \>>
DOCOMBresults in 5
Cheers, Werner
Edited: 6 Oct 2012, 1:38 p.m. after one or more responses were posted