Skip to content

A Haskell library for generalized positional notation manips

License

Notifications You must be signed in to change notification settings

queue-miscreant/GenBase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenBase

Typeclasses for numeric base conversions. Also provides functionality for bases defined by recurrence relations.

import Math.GenBase.Base (tobasei, frombasei, tobasef, frombasef, roundintf)
import Math.GenBase.Recur (Nnacci(..), count)

tobasei 2 10
-- [1,0,1,0] :: [Int]

tobasei (Nnacci 2) 10
-- [1,0,0,1,0] :: [Int]
-- i.e., the Zeckendorf expansion of 10

tobasef (Nnacci 2) 10
-- 10100.01001010101010101010101010101010101010101010101 :: Fp
-- an approximation of the phinary expansion of 10

count (Nnacci 2) !! 10
-- 10100.0101 :: Fp
-- an exact result for the phinary expansion of 10, produced by counting

frombasei 2 [1,0,1,0]
-- 10 :: Int

frombasei (Nnacci 2) [1,0,0,1,0]
-- 10 :: Int

frombasef (Nnacci 2) $ read "10100.0101"
-- 10.0 :: Double

roundintf (Nnacci 2) $ read "10100.0101"
-- Just 10 :: Maybe Int

roundintf (Nnacci 2) $ read "10100"
-- Nothing

About

A Haskell library for generalized positional notation manips

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published