slice

func slice(ls : List+String, range : List) -> List+String
  return [all ls(i) for i in range] when ls in List
  return concat([all ls(i) for i in range])

Returns the part of the given list or string that is indicated by the given range of indices. For example:
  slice(`a string value' [3..9]) = `string'
  slice(`a string value' [1..2, 10..14]) = `a value'

Note: This function may be too general. I have not yet had occasion to use it with more than a single range. In fact, the function currently does not behave as advertised when strings are sliced with multiple ranges. It may well be changed to accept the start and end indices of a single range as explicit parameters.


Herman Venter


This is Slim documentation as snarfed on 27 May 1999 by dB.