• Gets the value at index. It takes O(n).

    Parameters

    • index: number

      The position from 0 to get.

    Returns (<T>(list) => Option<T>)

    The element if exists.

    Examples

    import { atMay, range } from "./list.ts";
    import * as Option from "./option.ts";
    import { assertEquals } from "../deps.ts";

    const nums = range(1, 6);
    assertEquals(atMay(0)(nums), Option.some(1));
    assertEquals(atMay(4)(nums), Option.some(5));
    assertEquals(atMay(-1)(nums), Option.none());
    assertEquals(atMay(5)(nums), Option.none());

Generated using TypeDoc