From 386b38e483b4bc8d9d543fc4b8a16f2e66fdad12 Mon Sep 17 00:00:00 2001 From: mariari Date: Thu, 7 Nov 2024 15:18:59 +0800 Subject: [PATCH] Write the nth function --- Stdlib/Data/List/Base.juvix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Stdlib/Data/List/Base.juvix b/Stdlib/Data/List/Base.juvix index 589836ff..4ea06ecd 100644 --- a/Stdlib/Data/List/Base.juvix +++ b/Stdlib/Data/List/Base.juvix @@ -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;.