• Extracts digits of the number.

    Parameters

    • num: number

      The number to extract digits.

    • radix: number

      The radix of digit.

    Returns List<number>

    The list of digits of the number.

    Examples

    import { digits, toArray } from "./list.ts";
    import { assertEquals } from "../deps.ts";

    assertEquals(toArray(digits(51413, 10)), [3, 1, 4, 1, 5]);
    assertEquals(toArray(digits(0x51413, 16)), [3, 1, 4, 1, 5]);
    assertEquals(toArray(digits(0o51413, 8)), [3, 1, 4, 1, 5]);
    assertEquals(toArray(digits(0b1001011001, 2)), [
    1,
    0,
    0,
    1,
    1,
    0,
    1,
    0,
    0,
    1,
    ]);

    assertEquals(toArray(digits(0, 10)), []);

Generated using TypeDoc