Navigation
Synopsis Compute a sublist of a list.
Function list[&T] slice(list[&T] lst, int begin, int len)
Usage import List;
Description Returns a sublist of lst from index start of length len.
Examples
rascal>import List;
ok
rascal>slice([10, 20, 30, 40, 50, 60], 2, 3);
list[int]: [30,40,50]
rascal>slice(["zebra", "elephant", "snake", "owl"], 1, 2);
list[str]: ["elephant","snake"]

Questions
Question [1]. Computing slice(L, B, N) returns a list with:




Question [2].
The type of slice(["Yoda", "Eggplant", "T", "T", "Zekk"],0,2) is

Question [3].
slice(["Mumford the Magician", "Forgetful Jones", "Garlic", "Anakin Skywalker", "J"],1,3) == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.