Skip to content

Commit

Permalink
Write the nth function
Browse files Browse the repository at this point in the history
  • Loading branch information
mariari committed Nov 7, 2024
1 parent a567cf1 commit 386b38e
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 @@ -96,6 +96,10 @@ drop {A} : (elemsNum : Nat) -> (list : List A) -> List A
| (suc n) (x :: xs) := drop n xs
| _ xs := xs;

--- Take the nth value of a ;List;
nth {A} : Nat -> List A -> Maybe A
| n := drop n >> headMaybe;

--- 𝒪(𝓃). Returns a tuple where first element is the
--- prefix of the given list of length prefixLength and second element is the
--- remainder of the ;List;.
Expand Down

0 comments on commit 386b38e

Please sign in to comment.