Navigation
Synopsis Remove an arbitrary element from a list, returns the element and the modified list.
Function tuple[&T, list[&T]] takeOneFrom(list[&T] lst)
Usage import List;
Description Select an arbitrary element from lst, and return a tuple consisting of:
  • the selected element, and
  • a new list consisting of all elements of lst except the selected element.
See getOneFrom to only selected an element from a list.
Examples
rascal>import List;
ok
rascal>takeOneFrom([10,20,30,40,50]);
tuple[int,list[int]]: <10,[20,30,40,50]>
rascal>takeOneFrom([10,20,30,40,50]);
tuple[int,list[int]]: <50,[10,20,30,40]>
rascal>takeOneFrom([10,20,30,40,50]);
tuple[int,list[int]]: <10,[20,30,40,50]>
rascal>takeOneFrom(["zebra", "elephant", "snake", "owl"]);
tuple[str,list[str]]: <"snake",["zebra","elephant","owl"]>
rascal>takeOneFrom(["zebra", "elephant", "snake", "owl"]);
tuple[str,list[str]]: <"elephant",["zebra","snake","owl"]>
rascal>takeOneFrom(["zebra", "elephant", "snake", "owl"]);
tuple[str,list[str]]: <"snake",["zebra","elephant","owl"]>

Questions
Question [1].
The type of takeOneFrom([3, 6, -17, -9, 10, -15]) is



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.