(37 lines)
1 '\" t2 .\" Copyright (c) 2026 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH List.where 3 2026-03-08 "Tomo man-pages"6 .SH NAME7 List.where \- find an index where a predicate matches8 .SH LIBRARY9 Tomo Standard Library10 .SH SYNOPSIS11 .nf12 .BI List.where\ :\ func(list:\ [T],\ predicate:\ func(item:&T\ ->\ Bool)\ ->\ Int)13 .fi14 .SH DESCRIPTION15 Find the index of the first item that matches a predicate function (if any).18 .SH ARGUMENTS20 .TS21 allbox;22 lb lb lbx23 l l l.24 Name Type Description25 list [T] The list to search through.26 predicate func(item:&T -> Bool) A function that returns \fByes\fR if the item's index should be returned or \fBno\fR if it should not.27 .TE28 .SH RETURN29 Returns the index of the first item where the predicate is true or `none` if no item matches.31 .SH EXAMPLES32 .EX33 assert ["BC", "ABC", "CD"].where(func(t:&Text) t.starts_with("A")) == 234 assert ["BC", "ABC", "CD"].where(func(t:&Text) t.starts_with("X")) == none35 .EE36 .SH SEE ALSO37 .BR Tomo-List (3)