From 93aa20bdb15fbbad4e956d821a7d9a55d0a6bb7c Mon Sep 17 00:00:00 2001 From: ov7a Date: Sun, 31 Aug 2025 13:35:15 +0200 Subject: [PATCH] Add list.contains method --- lib/std/core/list.kk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/std/core/list.kk b/lib/std/core/list.kk index 27a1c843f..a0b48e764 100644 --- a/lib/std/core/list.kk +++ b/lib/std/core/list.kk @@ -529,6 +529,9 @@ pub fun any( xs : list, predicate : a -> e bool ) : e bool Cons(x,xx) -> if predicate(x) then True else xx.any(predicate) Nil -> False +pub fun contains( xs : list, item: a, ^?(==): (x: a, y: a) -> bool) : bool + xs.any(_ == item) + // Return the sum of a list of integers pub fun sum( xs : list ) : int xs.foldl( 0, fn(x,y) { x + y } )