Skip to content

Commit

Permalink
Array reverse helper (#1805)
Browse files Browse the repository at this point in the history
Really small. Just thought might not be appropriate to put in Keccak.
  • Loading branch information
qwang98 authored Sep 13, 2024
1 parent 9a0bd38 commit 2463391
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions std/array.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ let<T> set_element: T[], int, T -> T[] = |arr, i, x| {
/// Returns a new array of length l containing the elements of arr starting at index start.
let<T> sub_array: T[], int, int -> T[] = |arr, start, l| std::array::new(l, |i| arr[start + i]);

/// Returns a new array that reverses the input array.
let<T> reverse: T[] -> T[] = |arr| new(len(arr), |i| arr[len(arr) - i - 1]);

/// Evaluates to the array [f(arr[0]), f(arr[1]), ..., f(arr[len(arr) - 1])].
let<T1, T2> map: T1[], (T1 -> T2) -> T2[] = |arr, f| new(len(arr), |i| f(arr[i]));

Expand Down

0 comments on commit 2463391

Please sign in to comment.