![]() |
|
Navigation |
Synopsis Get number of elements from the head of a list.
Function
list[&T] take(int n, list[&T] lst)
Usage
import List;
Description Get
n elements (or size(lst) elements if size(lst) < n ) from the head of the list.
See drop to remove elements from the head of a list.
Examples
rascal>import List; ok rascal>take(2, [3, 1, 4, 5]); list[int]: [3,1] rascal>take(6, [3, 1, 4, 5]); list[int]: [3,1,4,5] rascal>take(2, ["zebra", "elephant", "snake", "owl"]); list[str]: ["zebra","elephant"] Questions
Question [1].
![]() ![]() take(M, L) of a list with N (N > M ) elements returns a list with
Question [2].
![]() ![]()
Question [3].
![]() ![]() ![]() |