uiua

Struct Array

Source
#[repr(C)]
pub struct Array<T> { /* private fields */ }
Expand description

Uiua’s array type

Implementations§

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn fill_to_shape(&mut self, shape: &[usize], fill_value: T)

Fill the array with the given value so it matches the given shape

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn join(self, other: Self, allow_ext: bool, env: &Uiua) -> UiuaResult<Self>

join the array with another

Source

pub fn join_infallible(self, other: Self, allow_ext: bool) -> Self

join the array with another

§Panics

Panics if the arrays have incompatible shapes

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn couple( self, other: Self, allow_ext: bool, env: &Uiua, ) -> UiuaResult<Self>

couple the array with another

Source

pub fn couple_infallible(self, other: Self, allow_ext: bool) -> Self

couple the array with another

§Panics

Panics if the arrays have incompatible shapes

Source

pub fn uncouple(self, env: &Uiua) -> UiuaResult<(Self, Self)>

Uncouple the array into two arrays

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn from_row_arrays<V>(values: V, env: &Uiua) -> UiuaResult<Self>
where V: IntoIterator<Item = Self>, V::IntoIter: ExactSizeIterator,

Create an array from row arrays

Source

pub fn from_row_arrays_infallible<V>(values: V) -> Self
where V: IntoIterator<Item = Self>, V::IntoIter: ExactSizeIterator,

Create an array from row arrays

§Panics

Panics if the row arrays have incompatible shapes

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn member(&self, of: &Self, env: &Uiua) -> UiuaResult<Array<u8>>

Check which rows of this array are members of another

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn index_of( &self, haystack: &Array<T>, env: &Uiua, ) -> UiuaResult<Array<f64>>

Get the index of the rows of this array in another

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn find(&self, haystack: &Self, env: &Uiua) -> UiuaResult<Array<u8>>

Try to find this array in another

Source

pub fn mask(&self, haystack: &Self, env: &Uiua) -> UiuaResult<Value>

Try to mask this array in another

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn take(self, index: &[Result<isize, bool>], env: &Uiua) -> UiuaResult<Self>

take from this array

Source

pub fn drop(self, index: &[Result<isize, bool>], env: &Uiua) -> UiuaResult<Self>

drop from this array

Source§

impl<T: Clone> Array<T>

Source

pub fn reshape_scalar( &mut self, count: Result<isize, bool>, env: &Uiua, ) -> UiuaResult

reshape this array by replicating it as the rows of a new array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn reshape( &mut self, dims: &[Result<isize, bool>], env: &Uiua, ) -> UiuaResult

reshape the array

Source§

impl<T: Clone + Send + Sync> Array<T>

Source

pub fn keep_scalar_integer(self, count: usize, env: &Uiua) -> UiuaResult<Self>

keep this array by replicating it as the rows of a new array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn keep_scalar_real(self, count: f64, env: &Uiua) -> UiuaResult<Self>

keep this array with a real-valued scalar

Source

pub fn keep_list(self, counts: &[f64], env: &Uiua) -> UiuaResult<Self>

keep this array with some counts

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn rotate(&mut self, by: Array<isize>, env: &Uiua) -> UiuaResult

rotate this array by the given amount

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn windows(&self, isize_spec: &[isize], env: &Uiua) -> UiuaResult<Self>

Get the windows of this array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn chunks(self, isize_spec: &[isize], env: &Uiua) -> UiuaResult<Self>

Get chunks of this array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn is_map(&self) -> bool

Check if the array is a map

Source

pub fn map_kv(&self) -> impl Iterator<Item = (Value, Array<T>)>

Get the keys and values of a map array

Source

pub fn map<C: ErrorContext>( &mut self, keys: Value, ctx: &C, ) -> Result<(), C::Error>

Create a map array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn deshape(&mut self)

Make the array 1-dimensional

Source

pub fn fix(&mut self)

Add a 1-length dimension to the front of the array’s shape

Source

pub fn unfix(&mut self, env: &Uiua) -> UiuaResult

Remove a 1-length dimension from the front of the array’s shape

Source

pub fn undo_fix(&mut self)

Collapse the top two dimensions of the array’s shape

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn first(self, env: &Uiua) -> UiuaResult<Self>

Get the first row of the array

Source

pub fn last(self, env: &Uiua) -> UiuaResult<Self>

Get the last row of the array

Source§

impl<T: Clone> Array<T>

Source

pub fn reverse(&mut self)

Reverse the rows of the array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn transpose(&mut self)

Transpose the array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn rise(&self) -> Array<f64>

Get the rise of the array

Source

pub fn fall(&self) -> Array<f64>

Get the fall of the array

Source

pub fn sort_up(&mut self)

Sort an array ascending

Source

pub fn sort_down(&mut self)

Sort an array descending

Source

pub fn classify(&self) -> Vec<usize>

classify the rows of the array

Source

pub fn deduplicate(&mut self, env: &Uiua) -> UiuaResult

deduplicate the rows of the array

Source

pub fn unique(&self) -> Array<u8>

Mask the unique rows of the array

Source

pub fn count_unique(&self) -> usize

Count the number of unique rows in the array

Source§

impl<T: RealArrayValue> Array<T>

Source

pub fn bits(&self, env: &Uiua) -> UiuaResult<Value>

Encode the bits of the array

Source§

impl<T> Array<T>
where T: RealArrayValue, Array<T>: Into<Value>,

Source

pub fn un_bits(&self, env: &Uiua) -> UiuaResult<Value>

Decode the bits of the array

Source§

impl<T> Array<T>

Source

pub fn new(shape: impl Into<Shape>, data: impl Into<CowSlice<T>>) -> Self

Create an array from a shape and data

§Panics

Panics in debug mode if the shape does not match the data length

Source

pub fn row_count(&self) -> usize

Get the number of rows in the array

Source

pub fn element_count(&self) -> usize

Get the number of elements in the array

Source

pub fn row_len(&self) -> usize

Get the number of elements in a row

Source

pub fn rank(&self) -> usize

Get the rank of the array

Source

pub fn shape(&self) -> &Shape

Get the shape of the array

Source

pub fn shape_mut(&mut self) -> &mut Shape

Get a mutable reference to the shape of the array

Source

pub fn elements(&self) -> impl ExactDoubleIterator<Item = &T>

Iterate over the elements of the array

Source

pub fn meta(&self) -> &ArrayMeta

Get the metadata of the array

Source

pub fn get_meta_mut(&mut self) -> Option<&mut ArrayMeta>

Get a mutable reference to the metadata of the array if it exists

Source

pub fn meta_mut(&mut self) -> &mut ArrayMeta

Get a mutable reference to the metadata of the array

Source

pub fn take_label(&mut self) -> Option<EcoString>

Take the label from the metadata

Source

pub fn take_map_keys(&mut self) -> Option<MapKeys>

Take the map keys from the metadata

Source

pub fn take_per_meta(&mut self) -> PersistentMeta

The the persistent metadata of the array

Source

pub fn set_per_meta(&mut self, per_meta: PersistentMeta)

Set the map keys in the metadata

Source

pub fn map_keys(&self) -> Option<&MapKeys>

Get a reference to the map keys

Source

pub fn map_keys_mut(&mut self) -> Option<&mut MapKeys>

Get a mutable reference to the map keys

Source

pub fn reset_meta_flags(&mut self)

Reset all metadata flags

Source

pub fn row_slices( &self, ) -> impl ExactSizeIterator<Item = &[T]> + DoubleEndedIterator + Clone + Send + Sync
where T: Send + Sync,

Get an iterator over the row slices of the array

Source

pub fn row_slice(&self, row: usize) -> &[T]

Get a slice of a row

Source

pub fn combine_meta(&mut self, other: &ArrayMeta)

Combine the metadata of two arrays

This combines:

  • flags
  • map keys
  • handle kind

Notably, this does not combine the label, as label combination should be more nuanced.

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn scalar(data: T) -> Self

Create a scalar array

Source

pub fn into_scalar(self) -> Result<T, Self>

Attempt to convert the array into a scalar

Source

pub fn as_scalar(&self) -> Option<&T>

Attempt to get a reference to the scalar value

Source

pub fn as_scalar_mut(&mut self) -> Option<&mut T>

Attempt to get a mutable reference to the scalar value

Source

pub fn rows( &self, ) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator + '_

Get an iterator over the row arrays of the array

Source

pub fn row_shaped_slices( &self, row_shape: Shape, ) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator + '_

Get an iterator over the row arrays of the array that have the given shape

Source

pub fn into_row_shaped_slices( self, row_shape: Shape, ) -> impl DoubleEndedIterator<Item = Self>

Get an iterator over the row arrays of the array that have the given shape

Source

pub fn row(&self, row: usize) -> Self

Get a row array

Source

pub fn slice_rows(&self, start: usize, end: usize) -> Self

Create an array that is a slice of this array’s rows

Generally doesn’t allocate

  • start must be <= end
  • start must be < self.row_count()
  • end must be <= self.row_count()
Source

pub fn into_rows( self, ) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator

Consume the array and get an iterator over its rows

Source

pub fn show(&self) -> String

Get a pretty-printed string representing the array

This is what is printed by the &s function

Source

pub fn row_slice_mut(&mut self, row: usize) -> &mut [T]

Get a mutable slice of a row

Source§

impl<T: Clone> Array<T>

Source

pub fn convert<U>(self) -> Array<U>
where T: Into<U> + 'static, U: Clone + 'static,

Convert the elements of the array

Source

pub fn convert_with<U: Clone>(self, f: impl FnMut(T) -> U) -> Array<U>

Convert the elements of the array with a function

Source

pub fn try_convert_with<U: Clone, E>( self, f: impl FnMut(T) -> Result<U, E>, ) -> Result<Array<U>, E>

Convert the elements of the array with a fallible function

Source

pub fn convert_ref<U>(&self) -> Array<U>
where T: Into<U>, U: Clone,

Convert the elements of the array without consuming it

Source

pub fn convert_ref_with<U: Clone>(&self, f: impl FnMut(T) -> U) -> Array<U>

Convert the elements of the array with a function without consuming it

Source§

impl Array<Boxed>

Source

pub fn into_unboxed(self) -> Result<Value, Self>

Attempt to unbox a scalar box array

Source

pub fn as_unboxed(&self) -> Option<&Value>

Attempt to unbox a scalar box array

Source

pub fn as_unboxed_mut(&mut self) -> Option<&mut Value>

Attempt to unbox a scalar box array

Source§

impl<T: ArrayValue> Array<T>

Source

pub fn shape_string(&self) -> String

Get a string representation of the shape of the array

Trait Implementations§

Source§

impl<T: Clone> Clone for Array<T>

Source§

fn clone(&self) -> Array<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ArrayValue> Debug for Array<T>
where Array<T>: GridFmt,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ArrayValue> Default for Array<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for Array<T>
where T: ArrayValueSer + Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: ArrayValue> Display for Array<T>
where Array<T>: GridFmt,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T: ArrayValue> From<&'a [T]> for Array<T>

Source§

fn from(data: &'a [T]) -> Self

Converts to this type from the input type.
Source§

impl From<Array<Boxed>> for Value

Source§

fn from(array: Array<Boxed>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<Complex>> for Value

Source§

fn from(array: Array<Complex>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<char>> for Value

Source§

fn from(array: Array<char>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<f64>> for Value

Source§

fn from(array: Array<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<u8>> for Value

Source§

fn from(array: Array<u8>) -> Self

Converts to this type from the input type.
Source§

impl<T: ArrayValue> From<EcoVec<T>> for Array<T>

Source§

fn from(data: EcoVec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Array<char>

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl<T: ArrayValue> From<T> for Array<T>

Source§

fn from(data: T) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<bool>> for Array<u8>

Source§

fn from(data: Vec<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<usize>> for Array<f64>

Source§

fn from(data: Vec<usize>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Array<u8>

Source§

fn from(data: bool) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a str> for Array<Boxed>

Source§

fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<String> for Array<Boxed>

Source§

fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: ArrayValue> FromIterator<T> for Array<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: ArrayValue> Hash for Array<T>

Source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: ArrayValue> Ord for Array<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: ArrayValue + ArrayCmp<U>, U: ArrayValue> PartialEq<Array<U>> for Array<T>

Source§

fn eq(&self, other: &Array<U>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ArrayValue + ArrayCmp<U>, U: ArrayValue> PartialOrd<Array<U>> for Array<T>

Source§

fn partial_cmp(&self, other: &Array<U>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Serialize for Array<T>
where T: ArrayValueSer + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: ArrayValue> Eq for Array<T>

Auto Trait Implementations§

§

impl<T> Freeze for Array<T>

§

impl<T> RefUnwindSafe for Array<T>
where T: RefUnwindSafe,

§

impl<T> Send for Array<T>
where T: Sync + Send,

§

impl<T> Sync for Array<T>
where T: Sync + Send,

§

impl<T> Unpin for Array<T>
where T: Unpin,

§

impl<T> UnwindSafe for Array<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,