I've been exploring the permutations and combinations functions for use in
class.  After seeing this:

sage: permutations(list('abc'))
[['a', 'b', 'c'], ['a', 'c', 'b'], ['b', 'a', 'c'], ['b', 'c', 'a'], ['c',
'a', 'b'], ['c', 'b', 'a']]

sage: permutations(var('a b c'))
[[a, b, c], [a, c, b], [b, a, c], [b, c, a], [c, a, b], [c, b, a]]

I then got this:

sage: combinations(list('abcde'), 3)
['abc', 'abd', 'abe', 'acd', 'ace', 'ade', 'bcd', 'bce', 'bde', 'cde']

sage: combinations(var('a b c d e'), 3)

RuntimeError: Gap produced error output
Variable: 'a' must have a value

Permutations of a list of strings returns a list of lists of strings, but
combinations from a list of strings returns a list of strings.

Also, permutations of a list of symbolic variables returns lists of symbolic
variables, but combinations from a list of symbolic variables produces a
runtime error.

There's no problem whatsoever in using lists of numbers, both the
combinations and permutations functions return the expected lists of values,
but there is this inconsistency when trying to use letters.

- Michel

-- 
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-...@googlegroups.com.
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en.

Reply via email to