aboutsummaryrefslogtreecommitdiff
path: root/std/magic/arrays.pk
blob: a0207c18bb0cd411a0234bf3a94df660ff4f559e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
## std.arrays: The array[T, S] primitive and associated functions.
## A stub module for documentation.

## Primitive fixed-size arrays. Their size is statically known at compile-time.
pub type array[T, S: static[uint]]

## Array access. Returns None if i is out of range.
pub func get[T, S: static[uint]](self: array[T, S], i: uint): T?
## Array mutation.
# todo: how do we detect range errors?
pub func set[T, S: static[uint]](self: mut array[T, S], i: uint, val: T): T?
## A helper function to get the length of an array.
## Known to the compiler, and computed at compile-time.
pub func len[T, S: static[uint]](self: array[T, S], i: uint): T?

type ArrayIter[T, S: static[uint]] = struct
  ...
pub func iter[T, S: static[uint]](self: array[T, S]): ArrayIter[T, S]

# todo: Eq, PartialEq, Ord, PartialOrd