Post Reply 
Symbolic Combinations and Permutations question.
01-13-2015, 02:09 AM
Post: #3
RE: Symbolic Combinations and Permutations question.
(01-13-2015 01:17 AM)Helge Gabert Wrote:  I don't know of any one built-in command that would do that, but the Prime, being fully programmable, allows you do something along these lines

EXPORT YOURNAME(n)
BEGIN
LOCAL a,l:={},ll:={},j:=1,k:=1;
a:=SIZE(n);
FOR j FROM 1 TO a-1 DO
FOR k FROM j+1 TO a DO
l:={{n(j),n(k)}};
ll:=CONCAT(ll,l);
END;
END;
RETURN ll;
END;

This will give you your desired pairs of combinations, and the code can be extended to return triplets, quadruplets, etc.

Thank you Helge Gabert,

I will modify it to work as nchoosek i matlab so you can give two arguments; list of elements an the number elements to choose.

Cheers
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Symbolic Combinations and Permutations question. - John P - 01-13-2015 02:09 AM



User(s) browsing this thread: 2 Guest(s)