-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyshape.mac
79 lines (72 loc) · 3.13 KB
/
yshape.mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Copyright (C) 2013 by Alessandro Campagni */
/*
* This file is part of YoungTableaux.
* YoungTableau is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* YoungTableaux is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with YoungTableaux. If not, see <http://www.gnu.org/licenses/>.
*
*
* Author: Alessandro Campagni <[email protected]>
*/
infix ("li=");
"li=" (ll,l) := block (
ret : true,
for i : 1 thru length (l) do if length (ll[i]) # l[i] then ret : false,
return (ret));
yshapep (t,d) :=
if (ydiagramp (d) and ytableaup (t)) then block (
ret : false,
if (length (t@word) = length (d@rows)) and (t@word li= d@rows) then ret : true,
return (ret))
else false;
/* returns the number of boxes in a diagram */
yshapesize (U) := sum (U@rows[i], i, 1, length (U@rows));
/* each time this function is called it attaches only one box in every */
/* possible position of the current diagram */
/* level should be 1 */
/* nextl should be [] */
attach_box (shape, ins, level, nextl) :=
if (ins > 0) then block (
[],
if (level <= length (shape)) then block (
[],
if (level > 1) then block (
[],
if (shape[level - 1] > shape[level]) then block ( /* we can attach at this level */
[curr],
curr : [copylist (shape), ins - 1],
curr[1][level] : shape[level] + 1,
nextl : append (nextl, [curr])),
return (attach_box (shape, ins, level + 1, nextl)))
else block (
[curr],
curr : [copylist (shape), ins - 1],
curr[1][1] : shape[1] + 1,
return (attach_box (shape, ins, level + 1, append (nextl, [curr])))))
else if (level = length (shape) + 1) then return (
attach_box (shape, ins, level + 1, append (nextl, [[append (shape, [1]), ins - 1]])))
else return (nextl))
else nextl;
/* given two words of two diagrams e and u, returns a list with all possible */
/* diagrams d fitting V=TU where V is a tableaux of shape d, T and U are tableaux */
/* of shape e and u respectively, and containing e. */
/* ds should be [[e,yshapesize(u)]] */
/* e is a reversed words */
yshape_product (ds) :=
if (not every (lambda ([x], is (x[2] = 0)), ds)) then block (
[curr,nextl],
curr : first (ds), /* we can use pop from */
ds : delete (curr, ds), /* basic.mac instead. */
nextl : attach_box (curr[1], curr[2], 1, []),
ds : append (ds, nextl),
return (yshape_product (ds)))
else ds; /* we're done */