2023-02-14 20:52:35 +0200 | received badge | ● Famous Question (source) |
2014-11-10 16:52:32 +0200 | received badge | ● Notable Question (source) |
2014-04-07 10:40:58 +0200 | received badge | ● Popular Question (source) |
2013-01-08 21:48:38 +0200 | commented answer | Recursive backtracking function: how to clear variables on new function call? I am not getting the same result with sst.list() though, so will look at that. It did occur to me that the tableau packages might be able to help but I could not quite see what to do. |
2013-01-08 21:47:44 +0200 | commented answer | Recursive backtracking function: how to clear variables on new function call? Wonderful, and many thanks! I am testing this and your code above seems to do exactly what I'd like. It seems that += rather than append is the way to go -- a key improvement -- and I will think about exactly how the placement of path_list = [] helped as well. |
2013-01-08 21:46:14 +0200 | received badge | ● Scholar (source) |
2013-01-08 21:46:14 +0200 | marked best answer | Recursive backtracking function: how to clear variables on new function call? I think the following code gives the good output (but is far from optimal, many computations are repeated again and again, as in the naive recursive computation of the Fibonacci sequence), here parameters are assumed to be partitions: For example: Actually we are computing functions already defined in Sage: Use Amitiés. |
2013-01-08 21:46:13 +0200 | received badge | ● Supporter (source) |
2013-01-04 18:50:38 +0200 | asked a question | Recursive backtracking function: how to clear variables on new function call? I've been trying to write a simple function to make lists of all the Young diagrams/partitions between a starting partition ('top') and an ending partition ('bot'), with each step in the list a covering relation (exactly one box difference in each step). For instance, I would like to input [2,1] for top and [1] for bot and get [[2,1],[2],[1]] [[2,1],[1,1],[1]] as my outputs. (I want to do this because it's useful for some computations with Littlewood-Richardson coefficients; having the lists that give each partition in a path between top and bot will be useful for other computations.) My code at present has an echo, and worse, I can't figure out where to initialize path_list. Where do I put path_list = [] -- or create other lists -- to make sure that:
(2) is worst: right now, since path_list is an internally-defined variable, I get the following bad behavior: sage: load "makepartitionlist.sage" sage: get_path([1],[1]) [[1]] [[1]] sage: get_path([1],[1]) [[1], [1]] [[1], [1]] sage: get_path([1],[1]) [[1], [1], [1]] [[1], [1], [1]] because path_list is not cleared when I call get_path again (which I'd hoped putting path_list = [] in the arguments would accomplish). The code: I'm using Sage 5.0.1 with Sage-combinat providing the Partition function and others. |