chickadee » srfi-116 » ilist-index

ilist-index pred ilist1 ilist2 ...procedure

Return the index of the leftmost element that satisfies pred.

If there are n ilist arguments ilist1 ... ilistn, then pred must be a function taking n arguments and returning a boolean result.

ilist-index applies pred to the first elements of the ilisti parameters. If this application returns true, ilist-index immediately returns zero. Otherwise, it iterates, applying pred to the second elements of the ilisti parameters, then the third, and so forth. When it finds a tuple of ilist elements that cause pred to return true, it stops and returns the zero-based index of that position in the ilists.

The iteration stops when one of the ilists runs out of values; in this case, ilist-index returns #f.

(ilist-index even? (iq 3 1 4 1 5 9))                  ;=> 2
(ilist-index < (iq 3 1 4 1 5 9 2 5 6) (iq 2 7 1 8 2)) ;=> 1
(ilist-index = (iq 3 1 4 1 5 9 2 5 6) (iq 2 7 1 8 2)) ;=> #f