2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -6,7 +6,3 @@ fractran fracts n = n :
|
|||
case find (\f -> n `mod` denominator f == 0) fracts of
|
||||
Nothing -> []
|
||||
Just f -> fractran fracts $ truncate (fromIntegral n * f)
|
||||
|
||||
main :: IO ()
|
||||
main = print $ take 15 $ fractran [17%91, 78%85, 19%51, 23%38, 29%33, 77%29,
|
||||
95%23, 77%19, 1%17, 11%13, 13%11, 15%14, 15%2, 55%1] 2
|
||||
1
Task/Fractran/Haskell/fractran-2.hs
Normal file
1
Task/Fractran/Haskell/fractran-2.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
import Data.List.Split (splitOn)
|
||||
3
Task/Fractran/Haskell/fractran-3.hs
Normal file
3
Task/Fractran/Haskell/fractran-3.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
readProgram :: String -> [Ratio a]
|
||||
readProgram = map (toFrac . splitOn "/") . splitOn ","
|
||||
where toFrac [n,d] = read n % read d
|
||||
1
Task/Fractran/Haskell/fractran-4.hs
Normal file
1
Task/Fractran/Haskell/fractran-4.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
import Data.Maybe (mapMaybe)
|
||||
6
Task/Fractran/Haskell/fractran-5.hs
Normal file
6
Task/Fractran/Haskell/fractran-5.hs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
primes = mapMaybe log2 $ fractran prog 2
|
||||
where
|
||||
prog = [17 % 91, 78 % 85, 19 % 51, 23 % 38, 29 % 33
|
||||
,77 % 29, 95 % 23, 77 % 19, 1 % 17, 11 % 13
|
||||
,13 % 11, 15 % 14, 15 % 2, 55 % 1]
|
||||
log2 = fmap (+ 1) . findIndex (== 2) . takeWhile even . iterate (`div` 2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue