Function in collections coil-stdlib

reverse

fn reverse<T>(Vec<T> arr) -> Vec<T>
Import
use collections::{reverse};
Source: src/collections.hy

Returns a copy of arr in reverse order.

Parameters#

NameType
arrVec<T>

Returns#

Vec<T>

Contracts#

Checked according to --contracts (see Contracts).

ensures result.len() == arr.len()

Examples#

use collections::{reverse};
use tests::assert;
let xs: Vec<int> = [1, 2, 3];
assert!(reverse(xs)[0] == 3);

See also#

  • sort: Returns a sorted copy of arr, in ascending order.
  • sort_by: Returns a copy of arr sorted by the value key gives each element, in ascending order.
  • collect_ints: Returns the values of the range a..b as a Vec<int>.
  • collect_ints_inclusive: Returns the values of the inclusive range a..=b as a Vec<int>.
↑ ↓ navigate ↵ open