Skip to content
FutureBlitz

    Install

    Import std.core.values

    std.core.values

    Small things for any values: the smaller and larger of two, a value kept between two others, swapping two variables, and a hash of two hashes.

    std/core/values.fb

    Functions

    Min function

    Public Function Min<T: Comparable>(a: T, b: T): T

    The smaller of the two, or the first when neither is.

    std/core/values.fb, line 12

    Max function

    Public Function Max<T: Comparable>(a: T, b: T): T

    The larger of the two, or the first when neither is.

    std/core/values.fb, line 15

    Clamp function

    @PanicsAtCaller Public Function Clamp<T: Comparable>(value: T, low: T, high: T): T

    The value, or low when it's below low, or high when it's above high. A high below low panics.

    Examples

    Expect(Clamp(15, 0, 10) == 10)
    Expect(Clamp(-0.5, 0.0, 1.0) == 0.0)
    Expect(Clamp("m", "a", "z") == "m")

    std/core/values.fb, line 27

    Swap function

    Public Function Swap<T>(ByRef a: T, ByRef b: T)

    Gives each of the two variables the other's value.

    std/core/values.fb, line 36

    HashCombine function

    Public Function HashCombine(first: UInt64, second: UInt64): UInt64

    A hash of the two hashes together, which depends on their order, for a Hash of several values.

    std/core/values.fb, line 43

    Report an issue with this page or with FutureBlitz on GitHub.