nimber-0.1.4: Finite nimber arithmetic

Data.Nimber

Description

The finite nimbers, Nimber, are a quadratically closed field of characteristic 2 introduced in combinatorial game theory.

>>> 257 + 258 :: Nimber
*3
>>> sqrt 123456789 :: Nimber
*98433322
>>> 123456789/sqrt 123456789 :: Nimber
*98433322


This implementation was inspired by Patrick Hurst’s slow Haskell implementation that this replaced (with his permission), and by Michel Van den Bergh’s Python implementation at https://web.archive.org/web/20101124110959/http://alpha.uhasselt.be/Research/Algebra/Members/nimbers/nimbers.py.

Synopsis

# Documentation

data Nimber Source #

The type of finite nimbers.

Instances
 Source # Instance detailsDefined in Data.Nimber MethodstoEnum :: Int -> Nimber #enumFrom :: Nimber -> [Nimber] #enumFromThen :: Nimber -> Nimber -> [Nimber] #enumFromTo :: Nimber -> Nimber -> [Nimber] #enumFromThenTo :: Nimber -> Nimber -> Nimber -> [Nimber] # Source # Instance detailsDefined in Data.Nimber Methods(==) :: Nimber -> Nimber -> Bool #(/=) :: Nimber -> Nimber -> Bool # Source # This partial Floating instance only supports sqrt. All other operations will throw the Innimerable exception. Instance detailsDefined in Data.Nimber Methodsexp :: Nimber -> Nimber #log :: Nimber -> Nimber #(**) :: Nimber -> Nimber -> Nimber #sin :: Nimber -> Nimber #cos :: Nimber -> Nimber #tan :: Nimber -> Nimber # Source # Note: Although nimbers support division, the fromRational operation makes little sense because Rationals are reduced according to ordinary multiplication instead of nimber multiplication. Instance detailsDefined in Data.Nimber Methods(/) :: Nimber -> Nimber -> Nimber # Source # Instance detailsDefined in Data.Nimber Methods(+) :: Nimber -> Nimber -> Nimber #(-) :: Nimber -> Nimber -> Nimber #(*) :: Nimber -> Nimber -> Nimber #abs :: Nimber -> Nimber # Source # Instance detailsDefined in Data.Nimber Methods(<) :: Nimber -> Nimber -> Bool #(<=) :: Nimber -> Nimber -> Bool #(>) :: Nimber -> Nimber -> Bool #(>=) :: Nimber -> Nimber -> Bool #max :: Nimber -> Nimber -> Nimber #min :: Nimber -> Nimber -> Nimber # Source # Instance detailsDefined in Data.Nimber Methods Source # Instance detailsDefined in Data.Nimber MethodsshowsPrec :: Int -> Nimber -> ShowS #showList :: [Nimber] -> ShowS #

Convert a Nimber to the corresponding natural number.

The type of exceptions thrown by impossible Nimber operations.

Constructors

 NegativeNimber A negative integer was converted to a nimber. Innimerable String A transcendental function was called on nimbers.
Instances
 Source # Instance detailsDefined in Data.Nimber Methods Source # Instance detailsDefined in Data.Nimber Methods Source # Instance detailsDefined in Data.Nimber MethodsshowList :: [NimberException] -> ShowS # Source # Instance detailsDefined in Data.Nimber Methods