From 7472837ee5a00bd9313e82f71f55b6f76ee7083b Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 18 Aug 2024 22:28:04 -0400 Subject: Add array:first(predicate:func(x:&T)->Bool)->@%T? --- test/arrays.tm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/arrays.tm b/test/arrays.tm index ac243018..c693996e 100644 --- a/test/arrays.tm +++ b/test/arrays.tm @@ -158,3 +158,14 @@ func main(): >> nums:sort(func(a,b:&%Int): a:abs() <> b:abs()) >> [nums:binary_search(i, func(a,b:&Int): a:abs() <> b:abs()) for i in nums] = [1, 2, 3, 4, 5] + + >> [10, 20, 30]:find(20) + = 2 + >> [10, 20, 30]:find(999) + = 0 + + >> [10, 20]:first(func(i:&Int): i:is_prime()) + = !Int + >> [4, 5, 6]:first(func(i:&Int): i:is_prime()) + = @%5? + -- cgit v1.2.3