Copyright | Anders Claesson 2015 |
---|---|
Maintainer | Anders Claesson <anders.claesson@gmail.com> |
Safe Haskell | None |
Language | Haskell98 |
License : BSD-3
Rational numbers extended with two elements representing a finite but indeterminate value and divison by zero, respectively.
- data Rat
- maybeRational :: Rat -> Maybe Rational
- maybeInteger :: Rat -> Maybe Integer
- maybeInt :: Rat -> Maybe Int
- isRational :: Rat -> Bool
- isInteger :: Rat -> Bool
- isInt :: Rat -> Bool
- factorial :: Rat -> Rat
- binomial :: Int -> Int -> Integer
- choose :: (Integral a, Num b) => a -> a -> b
- multinomial :: (Integral b, Fractional a) => [b] -> a
Documentation
Rationals extended with two elements:
Eq Rat Source # | |
Floating Rat Source # | |
Fractional Rat Source # | Division table: / | Val 0 | Val b | Indet | DZ ------+-------+-----------+-------+---- Val 0 | DZ | Val 0 | Val 0 | DZ Val a | DZ | Val (a/b) | Indet | DZ Indet | DZ | Indet | Indet | DZ DZ | DZ | DZ | DZ | DZ |
Num Rat Source # | Addition and multiplication tables: + | Val b | Indet | DZ ------+-----------+-------+---- Val a | Val (a+b) | Indet | DZ Indet | Indet | Indet | DZ DZ | DZ | DZ | DZ * | Val 0 | Val b | Indet | DZ ------+-------+-----------+-------+---- Val 0 | Val 0 | Val 0 | Val 0 | DZ Val a | Val 0 | Val (a*b) | Indet | DZ Indet | Val 0 | Indet | Indet | DZ DZ | DZ | DZ | DZ | DZ |
Ord Rat Source # | |
Read Rat Source # | |
Show Rat Source # | |
Pretty Rat Source # | |
maybeRational :: Rat -> Maybe Rational Source #
maybeRational
of Val x
is Just x
, otherwise it is Nothing
.
maybeInteger :: Rat -> Maybe Integer Source #
maybeInteger
of Val x
is Just
the numerator of x
if the
denominator of x
is 1, otherwise it is Nothing
.
maybeInt :: Rat -> Maybe Int Source #
Like maybeInteger
but return Nothing
when the integer is out of
range for an Int
.
isRational :: Rat -> Bool Source #
Is the given element a rational?
multinomial :: (Integral b, Fractional a) => [b] -> a Source #