Method code for $list.locate()

[Turn off line numbering]
  1: arg list, value;
  2: var idx;
  3: 
  4: return filter idx in [1 .. listlen(list)] where (value == list[idx]);
  5: 
  6: // Find the index in the list where the value of the element is the value being searched for.  Filter out the zeros so that only valid indices are returned.
  7: // [1, 2, 3, 4].locate(5) -> []
  8: // [4, 2, 3, 4].locate(4) -> [1, 4]

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon