Skip to content
FutureBlitz

    Install

    Import std.core.values

    std.core.values

    Min, Max, Clamp, Swap, and HashCombine, for any values.

    Examples

    Expect(Max(3, 7) == 7 && Min(3, 7) == 3)
    Local a = 1
    Local b = 2
    Swap(ByRef a, ByRef b)
    Expect(a == 2 && b == 1)
    // Its order counts, as a Hash of several values needs.
    Expect(HashCombine(1, 2) != HashCombine(2, 1))

    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.

    Examples

    Expect(Min(3, 7) == 3)
    Expect(Min("b", "a") == "a")

    std/core/values.fb, line 30

    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 33

    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 45

    Swap function

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

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

    Examples

    Local a = 1
    Local b = 2
    Swap(ByRef a, ByRef b)
    Expect(a == 2 && b == 1)

    std/core/values.fb, line 63

    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 70

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