Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
RealDice.Manipulate.GetValueFromRNGTable
Description
This module contains functions that get values from a list. These functions are used to get values from randomized tables for random generation purposes
Synopsis
- getBoolByIndex :: Int -> [Bool] -> Bool
- getIntByIndex :: Int -> [Int] -> Int
Documentation
getBoolByIndex :: Int -> [Bool] -> Bool Source #
Gets a boolean value from a list by index, looping back to the beginning if the index is out of bounds
After looping over the list once, we flip the values of the elements so that we can use an odd list length while still having an even distribution of True and False values
This is used to get an element from a randomized table of booleans
Examples
>>>
getBoolByIndex 2 [True, False, False, True, True]
False>>>
getBoolByIndex 5 [True, False, False, True, True]
False>>>
getBoolByIndex 6 [True, False, False, True, True]
True>>>
getBoolByIndex (-1337) [True, False, True, False, True]
False
getIntByIndex :: Int -> [Int] -> Int Source #
Gets an integer value from a list by index, looping back to the beginning if the index is out of bounds
This is used to get an element from a randomized table of integers
Examples
>>>
getIntByIndex 2 [1, 0, 4, 3, 2]
4>>>
getIntByIndex 5 [1, 0, 4, 3, 2]
1>>>
getIntByIndex (-1337) [1, 0, 4, 3, 2]
3