No matching definitions.

tur/slice

stdlib/slice.tur

typed Slice[A]: bounds-checked borrowed view into A elements.

Since: Phase TC1-C

defstruct

Slice

(defstruct Slice [A])

parameterized view into a contiguous array of A.

Since: Phase TC1

defn

slice-new

(slice-new [data :ptr<void> length :int])

create a Slice[A] view over an existing int64_t array.

datapointer to the start of the contiguous int64_t array
lengthnumber of elements in the view

A new Slice[A] view (does not copy the data).

(slice-new arr 4)  ; => slice of first 4 elements

Since: Phase TC1

defn

slice-len

(slice-len [s :int])

return the number of elements in a Slice[A].

sSlice[A] handle

Element count.

(slice-len s)  ; => 4

Since: Phase TC1

defn

slice-get

(slice-get [s :int i :int])

bounds-checked element access.

sSlice[A] handle
izero-based index

The element of type A at index i.

(slice-get s 0)  ; => first element

Since: Phase TC1

defn

slice-free

(slice-free [s :int])

free the Slice[A] header (does NOT free the underlying data).

sSlice[A] handle
(slice-free s)

Since: Phase TC1

defn

slice-eq?

(slice-eq? [s1 :int s2 :int cmp-fn])

compare two Slice[A] element-wise using a comparator.

s1first Slice[A]
s2second Slice[A]
cmp-fncomparator fn [a :int b :int] :bool

true if same length and all element pairs satisfy cmp-fn.

(slice-eq? sa sb (fn [a b] (= a b)))  ; => true

Since: Phase TC1