Skip to content

Commit

Permalink
Add the last function
Browse files Browse the repository at this point in the history
  • Loading branch information
mariari committed Nov 7, 2024
1 parent 0080b11 commit 2f8153e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Stdlib/Data/List/Base.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ head {A} (defaultValue : A) (list : List A) : A :=
| x :: _ := x
| nil := defaultValue;

--- 𝒪(𝓃). Grabs the last element of the given ;List;.
last {A} : A -> List A -> A
| default := reverse >> head default;

syntax iterator any {init := 0; range := 1};

--- 𝒪(𝓃). Returns ;true; if at least one element of the ;List; satisfies the predicate.
Expand Down

0 comments on commit 2f8153e

Please sign in to comment.