Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Math functions.
- type R = Double
- integral_and_fractional_parts :: (Integral i, RealFrac t) => t -> (i, t)
- integer_and_fractional_parts :: RealFrac t => t -> (Integer, t)
- fractional_part :: RealFrac a => a -> a
- sawtooth_wave :: RealFrac a => a -> a
- rational_pp :: (Show a, Integral a) => Ratio a -> String
- ratio_pp :: Rational -> String
- rational_simplifies :: Integral a => (a, a) -> Bool
- rational_nd :: Integral t => Ratio t -> (t, t)
- rational_whole :: Integral a => Ratio a -> Maybe a
- rational_whole_err :: Integral a => Ratio a -> a
- realfloat_pp :: RealFloat a => Int -> a -> String
- float_pp :: Int -> Float -> String
- double_pp :: Int -> Double -> String
- num_diff_str :: (Num a, Ord a, Show a) => a -> String
Documentation
integral_and_fractional_parts :: (Integral i, RealFrac t) => t -> (i, t) Source
integer_and_fractional_parts :: RealFrac t => t -> (Integer, t) Source
Type specialised.
fractional_part :: RealFrac a => a -> a Source
http://reference.wolfram.com/mathematica/ref/FractionalPart.html
import Sound.SC3.Plot {- hsc3-plot -} plotTable1 (map fractional_part [-2.0,-1.99 .. 2.0])
sawtooth_wave :: RealFrac a => a -> a Source
http://reference.wolfram.com/mathematica/ref/SawtoothWave.html
plotTable1 (map sawtooth_wave [-2.0,-1.99 .. 2.0])
rational_pp :: (Show a, Integral a) => Ratio a -> String Source
Pretty printer for Rational
that elides denominators of 1
.
map rational_pp [1,3/2,2] == ["1","3/2","2"]
ratio_pp :: Rational -> String Source
Pretty print ratio as :
separated integers.
map ratio_pp [1,3/2,2] == ["1:1","3:2","2:1"]
rational_simplifies :: Integral a => (a, a) -> Bool Source
Predicate that is true if n/d
can be simplified, ie. where
gcd
of n
and d
is not 1
.
let r = [False,True,False] in map rational_simplifies [(2,3),(4,6),(5,7)] == r
rational_nd :: Integral t => Ratio t -> (t, t) Source
numerator
and denominator
of rational.
rational_whole_err :: Integral a => Ratio a -> a Source
Erroring variant.
realfloat_pp :: RealFloat a => Int -> a -> String Source
Variant of showFFloat
. The Show
instance for floats resorts
to exponential notation very readily.
[show 0.01,realfloat_pp 2 0.01] == ["1.0e-2","0.01"]