From d343cc37a350d31ee6012596f6a369fb2c205550 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sat, 18 Jan 2025 16:06:00 -0500 Subject: [PATCH] Add List.contains to util --- src/Util.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Util.md b/src/Util.md index 92b301a..1d46e9e 100644 --- a/src/Util.md +++ b/src/Util.md @@ -31,6 +31,26 @@ Applies a function to the contents of a `Left` if the value of the given mapLeft f (Right x) = Right x ``` +## List + + + +### contains + +Returns `True` if the list contains the given value + +```idris +export +contains : Eq a => a -> List a -> Bool +contains x [] = False +contains x (y :: xs) = + if x == y + then True + else contains x xs +``` + ## Vectors Define some operations for pairs of numbers, treating them roughly like vectors