Commit 96447051 authored by sof's avatar sof
Browse files

[project @ 1997-05-18 01:38:54 by sof]

Type signatures added
parent 133dbf62
......@@ -12,18 +12,21 @@ import Array
data Radical = H | C Radical Radical Radical
three_partitions :: Int -> [(Int,Int,Int)]
three_partitions m =
[ (i,j,k) | i <- [0..(div m 3)], j <- [i..(div (m-i) 2)], k <- [m - (i+j)]]
remainders [] = []
remainders (r:rs) = (r:rs) : (remainders rs)
radical_generator :: Int -> Array Int [Radical]
radical_generator n =
radicals
where
radicals =
array (0,n) ((0,[H]) : [(j,rads_of_size_n radicals j) | j <- [1..n]])
rads_of_size_n :: Array Int [Radical] -> Int -> [Radical]
rads_of_size_n radicals n =
[ (C ri rj rk)
| (i,j,k) <- (three_partitions (n-1)),
......@@ -35,19 +38,22 @@ rads_of_size_n radicals n =
data Paraffin = BCP Radical Radical | CCP Radical Radical Radical Radical
bcp_generator :: Array Int [Radical] -> Int -> [Paraffin]
bcp_generator radicals n =
if (odd n) then []
else
[ (BCP r1 r2) | (r1:r1s) <- (remainders (radicals!(div n 2))),
r2 <- (r1:r1s) ]
four_partitions :: Int -> [(Int,Int,Int,Int)]
four_partitions m =
[ (i,j,k,l)
| i <- [0..(div m 4)],
j <- [i..(div (m-i) 3)],
k <- [(max j (ceiling ((fromInteger m)/(fromInteger 2)) - i - j))..(div (m-i-j) 2)],
k <- [(max j (ceiling ((fromIntegral m)/(fromInt 2)) - i - j))..(div (m-i-j) 2)],
l <- [(m - (i+j+k))]]
ccp_generator :: Array Int [Radical] -> Int -> [Paraffin]
ccp_generator radicals n =
[ (CCP ri rj rk rl)
| (i,j,k,l) <- (four_partitions (n-1)),
......@@ -56,16 +62,19 @@ ccp_generator radicals n =
(rk:rks) <- (remainders (if (j==k) then (rj:rjs) else radicals!k)),
rl <- (if (k==l) then (rk:rks) else radicals!l)]
bcp_until :: Int -> [Int]
bcp_until n =
[length(bcp_generator radicals j) | j <- [1..n]]
where
radicals = radical_generator (div n 2)
ccp_until :: Int -> [Int]
ccp_until n =
[length(ccp_generator radicals j) | j <- [1..n]]
where
radicals = radical_generator (div n 2)
paraffins_until :: Int -> [Int]
paraffins_until n =
[length (bcp_generator radicals j) + length (ccp_generator radicals j)
| j <- [1..n]]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment