dev
Download
37 lines 959 BGroffModified 2026-03-09 raw
12345678910111213141516171819202122232425262728293031323334353637
'\" t
.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
.TH List.where 3 2026-03-08 "Tomo man-pages"
.SH NAME
List.where \- find an index where a predicate matches
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI List.where\ :\ func(list:\ [T],\ predicate:\ func(item:&T\ ->\ Bool)\ ->\ Int)
.fi
.SH DESCRIPTION
Find the index of the first item that matches a predicate function (if any).


.SH ARGUMENTS

.TS
allbox;
lb lb lbx
l l l.
Name	Type	Description
list	[T]	The list to search through. 
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. 
.TE
.SH RETURN
Returns the index of the first item where the predicate is true or `none` if no item matches.

.SH EXAMPLES
.EX
assert ["BC", "ABC", "CD"].where(func(t:&Text) t.starts_with("A")) == 2
assert ["BC", "ABC", "CD"].where(func(t:&Text) t.starts_with("X")) == none
.EE
.SH SEE ALSO
.BR Tomo-List (3)