From 2f8153e292f7999a779e1f3016a6629c49da8371 Mon Sep 17 00:00:00 2001 From: mariari Date: Thu, 7 Nov 2024 12:55:53 +0800 Subject: [PATCH] Add the last 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 bc8d0900..de956180 100644 --- a/Stdlib/Data/List/Base.juvix +++ b/Stdlib/Data/List/Base.juvix @@ -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.