aboutsummaryrefslogtreecommitdiff
path: root/Math/Combinatorics/YoungTableaux.hs
blob: e365ee7e26b163e56fc22ed051d87134e4cf83ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
isRowWord' :: Ord a => [a] -> [a] -> [a] -> Bool
isRowWord' _  ys [] = ys == []
isRowWord' [] [] zs = isRowWord' [head zs] [] (tail zs)
isRowWord' xs [] zs = if last xs <= head zs then isRowWord' (xs ++ [head zs]) [] (tail zs) else isRowWord' [] xs zs
isRowWord' xs ys zs = 
  if xs == [] || last xs <= head zs
    then head ys > head zs && (isRowWord' (xs ++ [head zs]) (tail ys) (tail zs))
    else ys == [] && isRowWord' [] xs zs

isRowWord :: Ord a => [a] -> Bool
isRowWord = isRowWord' [] []

reduceWord :: Ord a => [a] -> [a]
reduceWord xs
  | length xs <= 2 = xs
  | otherwise      = reduceWord' (reduceWord (init xs)) (last xs)

reduceWord' :: Ord a => [a] -> a -> [a]
reduceWord' xs x =