Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Functions for dealing with step functions.
- data Transition x y = Transition {
- x_val :: x
- y_val :: y
- left_closed :: Bool
- data StepFunction x y
- mkStepFunction :: (Ord x, Eq y) => y -> [Transition x y] -> StepFunction x y
- valAt :: Ord x => x -> StepFunction x y -> y
- transitions :: StepFunction x y -> [Transition x y]
- merge :: (Ord x, Eq c) => (a -> b -> c) -> StepFunction x a -> StepFunction x b -> StepFunction x c
Documentation
data Transition x y Source #
A Transition, for a certain value on the x axis, there is a new y value.
Transition | |
|
data StepFunction x y Source #
A StepFunction is implemented as a default value and a sorted list of Transitions.
mkStepFunction :: (Ord x, Eq y) => y -> [Transition x y] -> StepFunction x y Source #
Smart constructor sorts and simplifies the list of transitions.
valAt :: Ord x => x -> StepFunction x y -> y Source #
Get the y value for a given x.
transitions :: StepFunction x y -> [Transition x y] Source #
The transitions.
merge :: (Ord x, Eq c) => (a -> b -> c) -> StepFunction x a -> StepFunction x b -> StepFunction x c Source #
Merge two step function, such that the following should be true:
valAt x (merge f sf1 sf2) == f (valAt x sf1) (valAt x sf2)
The resulting step function will be simplified, transitions that don't change the y value will be eliminated, and transitions that happen on the same x position will be eliminated.