From 51ca2f7e55f1c909b8e0bcc07276ace34818b3ae Mon Sep 17 00:00:00 2001 From: dnt Date: Tue, 26 Nov 1996 14:46:51 +0000 Subject: [PATCH] [project @ 1996-11-26 14:46:20 by dnt] Merged in changes from new-build-system branch --- imaginary/Jmakefile | 10 -- imaginary/Makefile | 3 + imaginary/exp3_8/Jmakefile | 1 - imaginary/exp3_8/Makefile | 3 + imaginary/exp3_8/exp3_8.stdout | 2 +- imaginary/gen_regexps/Jmakefile | 1 - imaginary/gen_regexps/Makefile | 3 + imaginary/paraffins/Jmakefile | 1 - imaginary/paraffins/Main.hs | 140 ++++++++++----------------- imaginary/paraffins/Makefile | 3 + imaginary/paraffins/paraffins.stdout | 4 + imaginary/primes/Jmakefile | 1 - imaginary/primes/Main.hs | 1 - imaginary/primes/Makefile | 3 + imaginary/queens/Jmakefile | 1 - imaginary/queens/Makefile | 3 + imaginary/rfib/Jmakefile | 1 - imaginary/rfib/Makefile | 3 + imaginary/tak/Jmakefile | 1 - imaginary/tak/Makefile | 3 + imaginary/x2n1/Jmakefile | 1 - imaginary/x2n1/Main.hs | 5 +- imaginary/x2n1/Makefile | 3 + imaginary/x2n1/x2n1.stdout | 2 +- 24 files changed, 89 insertions(+), 110 deletions(-) delete mode 100644 imaginary/Jmakefile create mode 100644 imaginary/Makefile delete mode 100644 imaginary/exp3_8/Jmakefile create mode 100644 imaginary/exp3_8/Makefile delete mode 100644 imaginary/gen_regexps/Jmakefile create mode 100644 imaginary/gen_regexps/Makefile delete mode 100644 imaginary/paraffins/Jmakefile create mode 100644 imaginary/paraffins/Makefile delete mode 100644 imaginary/primes/Jmakefile create mode 100644 imaginary/primes/Makefile delete mode 100644 imaginary/queens/Jmakefile create mode 100644 imaginary/queens/Makefile delete mode 100644 imaginary/rfib/Jmakefile create mode 100644 imaginary/rfib/Makefile delete mode 100644 imaginary/tak/Jmakefile create mode 100644 imaginary/tak/Makefile delete mode 100644 imaginary/x2n1/Jmakefile create mode 100644 imaginary/x2n1/Makefile diff --git a/imaginary/Jmakefile b/imaginary/Jmakefile deleted file mode 100644 index cd61684..0000000 --- a/imaginary/Jmakefile +++ /dev/null @@ -1,10 +0,0 @@ -#define IHaveSubdirs - -SUBDIRS = exp3_8 \ - gen_regexps \ - primes \ - queens \ - rfib \ - tak - -/* nfib: DIE, ANIMAL! */ diff --git a/imaginary/Makefile b/imaginary/Makefile new file mode 100644 index 0000000..0acf1a8 --- /dev/null +++ b/imaginary/Makefile @@ -0,0 +1,3 @@ +TOP = ../.. +SUBDIRS = exp3_8 gen_regexps paraffins primes queens rfib tak x2n1 +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/exp3_8/Jmakefile b/imaginary/exp3_8/Jmakefile deleted file mode 100644 index 8e2ec67..0000000 --- a/imaginary/exp3_8/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(exp3_8,) diff --git a/imaginary/exp3_8/Makefile b/imaginary/exp3_8/Makefile new file mode 100644 index 0000000..e018a6a --- /dev/null +++ b/imaginary/exp3_8/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = exp3_8 +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/exp3_8/exp3_8.stdout b/imaginary/exp3_8/exp3_8.stdout index ce80ee7..c4ab99b 100644 --- a/imaginary/exp3_8/exp3_8.stdout +++ b/imaginary/exp3_8/exp3_8.stdout @@ -1 +1 @@ -6561 \ No newline at end of file +6561 diff --git a/imaginary/gen_regexps/Jmakefile b/imaginary/gen_regexps/Jmakefile deleted file mode 100644 index da62fb8..0000000 --- a/imaginary/gen_regexps/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(gen_regexps,-i gen_regexps.stdin) diff --git a/imaginary/gen_regexps/Makefile b/imaginary/gen_regexps/Makefile new file mode 100644 index 0000000..2160c80 --- /dev/null +++ b/imaginary/gen_regexps/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = gen_regexps +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/paraffins/Jmakefile b/imaginary/paraffins/Jmakefile deleted file mode 100644 index a78993f..0000000 --- a/imaginary/paraffins/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(paraffins,-i paraffins.stdin) diff --git a/imaginary/paraffins/Main.hs b/imaginary/paraffins/Main.hs index 17d3acd..ee9b35e 100644 --- a/imaginary/paraffins/Main.hs +++ b/imaginary/paraffins/Main.hs @@ -1,115 +1,79 @@ -{- Ensnaffled by SLPJ from MIT - via RPaul 93/08/26. --} +{- + - Id Example Program + - Ensnaffled by SLPJ from MIT via + - RPaul 93/08/26. + - Original author: Steve Heller + -} --- Id Example Program --- Title: Paraffins --- Original Author: Steve Heller +module Main (main) where +import Array --- Needs the following library functions --- typeof div = I -> I -> I; --- typeof ceiling = F -> I; --- typeof float = I -> F; --- typeof length = (list *0) -> I; --- typeof odd? = I -> B; --- typeof max = I -> I -> I; - -module Main where - --- Generation of radicals. +-- Generation of radicals data Radical = H | C Radical Radical Radical three_partitions m = - [ (i,j,k) | i <- [0..(div m 3)], - j <- [i..(div (m-i) 2)], - k <- [(m - (i+j))]] + [ (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 n = radicals where - { radicals = array (0,n) - ((0 := [H]): - [j := (rads_of_size_n radicals j) | j <- [1..n]])} - - --- $[1 1 1 2 4 8 17 39 89 211 507 1238 3057 7639 19241 48865 124906 321198] -test_radicals n = - array (0,n) [i := (length (rads!i)) | rads <- [(radical_generator n)], - i <- [0..n]] +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 radicals n = - [ (C ri rj rk) | (i,j,k) <- (three_partitions (n-1)), - (ri:ris) <- (remainders (radicals!i)), - (rj:rjs) <- (remainders (if (i==j) then (ri:ris) else radicals!j)), - rk <- (if (j==k) then (rj:rjs) else radicals!k)] + [ (C ri rj rk) + | (i,j,k) <- (three_partitions (n-1)), + (ri:ris) <- (remainders (radicals!i)), + (rj:rjs) <- (remainders (if (i==j) then (ri:ris) else radicals!j)), + rk <- (if (j==k) then (rj:rjs) else radicals!k)] -- Generation of paraffins. data Paraffin = BCP Radical Radical | CCP Radical Radical Radical Radical bcp_generator radicals n = - if (odd n) then - [] + if (odd n) then [] else [ (BCP r1 r2) | (r1:r1s) <- (remainders (radicals!(div n 2))), r2 <- (r1:r1s) ] 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)], - l <- [(m - (i+j+k))]] + [ (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)], + l <- [(m - (i+j+k))]] ccp_generator radicals n = - [ (CCP ri rj rk rl) | (i,j,k,l) <- (four_partitions (n-1)), - (ri:ris) <- (remainders (radicals!i)), - (rj:rjs) <- (remainders (if (i==j) then (ri:ris) else radicals!j)), - (rk:rks) <- (remainders (if (j==k) then (rj:rjs) else radicals!k)), - rl <- (if (k==l) then (rk:rks) else radicals!l)] - -bcp_until n = let - { radicals = radical_generator (div n 2)} - in - array (1,n) [j := (bcp_generator radicals j) | j <- [1..n]] - -ccp_until n = let - { radicals = radical_generator (div n 2)} - in - array (1,n) [j := (ccp_generator radicals j) | j <- [1..n]] - -ccp_at n = let - { radicals = radical_generator (div n 2)} - in - (ccp_generator radicals n) - -paraffins_until n = let - { radicals = radical_generator (div n 2)} - in - array (1,n) [j := ((bcp_generator radicals j),(ccp_generator radicals j)) | j <- [1..n]] - --- $[0 1 0 1 0 3 0 10 0 36 0 153 0 780 0 4005 0] -test_bcp_until n = let - { result = bcp_until n} - in - - array (1,n) [i := (length (result!i)) | i <- [1..n]] - --- $[1 0 1 1 3 2 9 8 35 39 159 202 802 1078 4347 6354 24894] -test_ccp_until n = let - { result = ccp_until n} - in - array (1,n) [i := (length (result!i)) | i <- [1..n]] - --- $[1 1 1 2 3 5 9 18 35 75 159 355 802 1858 4347 10359 24894] -test_paraffins_until n = let - { result = paraffins_until n} - in - array (1,n) [i := (let { (bv,cv) = result!i} in (length bv) + (length cv)) - | i <- [1..n]] + [ (CCP ri rj rk rl) + | (i,j,k,l) <- (four_partitions (n-1)), + (ri:ris) <- (remainders (radicals!i)), + (rj:rjs) <- (remainders (if (i==j) then (ri:ris) else radicals!j)), + (rk:rks) <- (remainders (if (j==k) then (rj:rjs) else radicals!k)), + rl <- (if (k==l) then (rk:rks) else radicals!l)] + +bcp_until n = + [length(bcp_generator radicals j) | j <- [1..n]] + where + radicals = radical_generator (div n 2) + +ccp_until n = + [length(ccp_generator radicals j) | j <- [1..n]] + where + radicals = radical_generator (div n 2) + +paraffins_until n = + [length (bcp_generator radicals j) + length (ccp_generator radicals j) + | j <- [1..n]] + where + radicals = radical_generator (div n 2) main = do - putStr "Type in N: " - input <- getContents - putStr (show (test_paraffins_until (read (head (lines input))))) + print [length (rads!i) | rads <- [(radical_generator 17)], i <- [0..17]] + print (bcp_until 17) + print (ccp_until 17) + print (paraffins_until 17) diff --git a/imaginary/paraffins/Makefile b/imaginary/paraffins/Makefile new file mode 100644 index 0000000..bbf09d5 --- /dev/null +++ b/imaginary/paraffins/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = paraffins +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/paraffins/paraffins.stdout b/imaginary/paraffins/paraffins.stdout index e69de29..3a69f7c 100644 --- a/imaginary/paraffins/paraffins.stdout +++ b/imaginary/paraffins/paraffins.stdout @@ -0,0 +1,4 @@ +[1, 1, 1, 2, 4, 8, 17, 39, 89, 211, 507, 1238, 3057, 7639, 19241, 48865, 124906, 321198] +[0, 1, 0, 1, 0, 3, 0, 10, 0, 36, 0, 153, 0, 780, 0, 4005, 0] +[1, 0, 1, 1, 3, 2, 9, 8, 35, 39, 159, 202, 802, 1078, 4347, 6354, 24894] +[1, 1, 1, 2, 3, 5, 9, 18, 35, 75, 159, 355, 802, 1858, 4347, 10359, 24894] diff --git a/imaginary/primes/Jmakefile b/imaginary/primes/Jmakefile deleted file mode 100644 index 0606545..0000000 --- a/imaginary/primes/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(primes,) diff --git a/imaginary/primes/Main.hs b/imaginary/primes/Main.hs index d6aabc3..c4b5a56 100644 --- a/imaginary/primes/Main.hs +++ b/imaginary/primes/Main.hs @@ -11,4 +11,3 @@ primes :: [Int] primes = map head (iterate the_filter (iterate suCC 2)) main = print (primes !! 1500) ---OLD: main = print (take 300 primes) diff --git a/imaginary/primes/Makefile b/imaginary/primes/Makefile new file mode 100644 index 0000000..deff97d --- /dev/null +++ b/imaginary/primes/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = primes +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/queens/Jmakefile b/imaginary/queens/Jmakefile deleted file mode 100644 index 7dcf86c..0000000 --- a/imaginary/queens/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(queens,) diff --git a/imaginary/queens/Makefile b/imaginary/queens/Makefile new file mode 100644 index 0000000..f3a64c4 --- /dev/null +++ b/imaginary/queens/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = queens +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/rfib/Jmakefile b/imaginary/rfib/Jmakefile deleted file mode 100644 index 1010e90..0000000 --- a/imaginary/rfib/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(rfib,) diff --git a/imaginary/rfib/Makefile b/imaginary/rfib/Makefile new file mode 100644 index 0000000..12c67cc --- /dev/null +++ b/imaginary/rfib/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = rfib +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/tak/Jmakefile b/imaginary/tak/Jmakefile deleted file mode 100644 index e06ca5d..0000000 --- a/imaginary/tak/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(tak,) diff --git a/imaginary/tak/Makefile b/imaginary/tak/Makefile new file mode 100644 index 0000000..cc60391 --- /dev/null +++ b/imaginary/tak/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = tak +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/x2n1/Jmakefile b/imaginary/x2n1/Jmakefile deleted file mode 100644 index 21765fb..0000000 --- a/imaginary/x2n1/Jmakefile +++ /dev/null @@ -1 +0,0 @@ -NoFibOneModuleCompileAndRun(x2n1,) diff --git a/imaginary/x2n1/Main.hs b/imaginary/x2n1/Main.hs index a57da72..dc8d7e7 100644 --- a/imaginary/x2n1/Main.hs +++ b/imaginary/x2n1/Main.hs @@ -23,7 +23,10 @@ of all the other programs I thought I'd contribute at least one :-) ... -} -main = prints (round (realPart (sum [f n | n<-[1..10000]]))) "\n" +module Main ( main ) where +import Complex + +main = print (round (realPart (sum [f n | n <- [1..10000]]))) f :: Int -> Complex Double f n = mkPolar 1 (2*pi/fromInt n) ^ n diff --git a/imaginary/x2n1/Makefile b/imaginary/x2n1/Makefile new file mode 100644 index 0000000..81cb883 --- /dev/null +++ b/imaginary/x2n1/Makefile @@ -0,0 +1,3 @@ +TOP = ../../.. +PROG = x2n1 +include $(TOP)/nofib/mk/nofib.mk diff --git a/imaginary/x2n1/x2n1.stdout b/imaginary/x2n1/x2n1.stdout index ce80ee7..5caff40 100644 --- a/imaginary/x2n1/x2n1.stdout +++ b/imaginary/x2n1/x2n1.stdout @@ -1 +1 @@ -6561 \ No newline at end of file +10000 -- GitLab