I was trying to list the King tableaux of a particular shape. Here's the 
function:

def list_of_king_tableaux(t_shape, t_max_entry):
    """A function which finds the list of King tableaux of given shape."""
    return list([t for t in SemistandardTableaux(t_shape, 
max_entry=t_max_entry) if is_king_tableau(t)])

And this is the output I got:

sage: list_of_king_tableaux([2,2],4)
[[[1, 1], [3, 3]],
 [[1, 1], [3, 4]],
 [[1, 1], [4, 4]],
 [[1, 2], [3, 3]],
 [[1, 2], [3, 4]],
 [[1, 2], [4, 4]],
 [[1, 3], [3, 4]],
 [[1, 3], [4, 4]]]

The list shows the tableaux that are not king tableaux. How do I choose the 
ones that obey the king tableaux condition?



On Monday, March 9, 2020 at 4:54:48 AM UTC-4, Bruce wrote:
>
> The king_tableaux is an iterator not a function.
> it is used in the last three lines.
>
> if you want a list look inside no_of_king_tableaux
>
> On Sunday, 8 March 2020 21:41:34 UTC, Soheli Das wrote:
>>
>> Thank you Bruce!! Indeed the function looks tidier. 
>> The third function gives me this message: "<generator object 
>> king_tableaux at 0x6ffea35729a8>". The 'p' is supposed to mean the 
>> partition right?
>>
>> Once again thank you for your help. I really appreciate it!
>>
>> -Soheli
>>
>> On Sunday, March 8, 2020 at 5:26:41 AM UTC-4, Bruce wrote:
>>>
>>> Thank you for helping me. I created the function:
>>>
>>> sage: def is_king_tableau(t,no_of_rows):
>>> ....:     for i in range(no_of_rows):
>>> ....:         if t[0][0] != 1:
>>> ....:             return False
>>> ....:         elif t[i][0] <= 2*i:
>>> ....:             return False
>>> ....:         else:
>>> ....:             i=i+1
>>> ....:     return True
>>>
>>>
>>> I have tidied up your function and written some simple functions to show 
>>> how it is used.
>>> I hope this will encourage you to learn more about Python, make further 
>>> improvements and write your own functions.
>>>
>>> The last three lines are not a function but use the iterator to show the 
>>> motivation for the definition of a King tableau.
>>>
>>> def is_king_tableau(t):
>>>     """A function which tests if a semistandard tableau is a King 
>>> tableau."""
>>>     if t[0][0] != 1:
>>>         return False    
>>>     for i, row in enumerate(t):
>>>         if row[0] <= 2*i:
>>>             return False
>>>     return True
>>>
>>> def no_of_king_tableaux(p):
>>>     """A function which finds the number of King tableaux of given 
>>> shape."""
>>>     return len([t for t in SemistandardTableaux(p) if 
>>> is_king_tableau(t)])
>>>
>>> def king_tableaux(p):
>>>     """An iterator for the set of King tableaux of given shape."""
>>>     for t in SemistandardTableaux(p):
>>>         if is_king_tableau(t):
>>>             yield t
>>>
>>> for t in king_tableaux([2,2]):
>>>     t.to_Gelfand_Tsetlin_pattern().pp()
>>>     print "\n"
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-combinat-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-combinat-devel/ed8d2d66-6f26-4f69-8f69-8beee43e0161%40googlegroups.com.

Reply via email to