swarm-0.5.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Util.UnitInterval

Description

Creation and utilities for the unit interval

Synopsis

Documentation

mkInterval :: (Ord a, Num a) => a -> UnitInterval a Source #

Guarantees that the stored value falls within the closed interval [0, 1]. It is up to clients to ensure that the promotion to this type is lossless.

safeIndex Source #

Arguments

:: RealFrac a 
=> UnitInterval a

alpha

-> NonEmpty b 
-> b 

Since (!!) is partial, here is "proof" that it is safe: If "alpha" is its maximum value of 1, then the maximum value of the computed index shall be one less than the length of the list (i.e., a valid index).

See also: indexWrapNonEmpty.