From 785087aa43cf962855724b8fa5da393022204a14 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Sep 2022 13:12:19 +0200 Subject: Add $find(, ), $find_index(, ) functions The $find() function returns true if the sequence contains the specified value. The $find_index() function returns the index of the first element in the sequence that is equal to the specified value or $size() if none is found. For string sequences, it's possible to request case- insensitive comparison with a flag. --- tests/function/name/testscript | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tests/function/name') diff --git a/tests/function/name/testscript b/tests/function/name/testscript index 6222167..4588e1d 100644 --- a/tests/function/name/testscript +++ b/tests/function/name/testscript @@ -49,6 +49,20 @@ : sort : { - $* <'print $sort( d/t{a} t{c b} d/t{a})' >'t{b} t{c} d/t{a} d/t{a}' : basics - $* <'print $sort( d/t{a} t{c b} d/t{a}, dedup)' >'t{b} t{c} d/t{a}' : dedup + $* <'print $sort(d/t{a} t{c b} d/t{a})' >'t{b} t{c} d/t{a} d/t{a}' : basics + $* <'print $sort(d/t{a} t{c b} d/t{a}, dedup)' >'t{b} t{c} d/t{a}' : dedup +} + +: find +: +{ + $* <'print $find([names] d/t{a} t{a b}, t{a})' >'true' : basics-true + $* <'print $find([names] d/t{a} t{a b}, d/t{b})' >'false' : basics-false +} + +: find_index +: +{ + $* <'print $find_index([names] d/t{a} t{a b}, t{a})' >'1' : basics-true + $* <'print $find_index([names] d/t{a} t{a b}, d/t{b})' >'3' : basics-false } -- cgit v1.1