Skip to content

Take

Returns the first n elements of a list.

$ wo 'Take[{1, 2, 3, 4, 5}, 3]'
{1, 2, 3}
$ wo 'Take[{1, 2, 3, 4, 5}, 1]'
{1}
$ wo 'Take[{1, 2, 3}, 5]'

Take::take: Cannot take positions 1 through 5 in {1, 2, 3}.
.* (regex*)
Take[{1, 2, 3}, 5]
$ wo 'Take[{a, b, c, d}, 2]'
{a, b}
$ wo 'Take[{1.5, 2.5, 3.5, 4.5}, 2]'
{1.5, 2.5}
$ wo 'Take[{10, 20, 30, 40}, 4]'
{10, 20, 30, 40}
$ wo 'Take[{1, 2, 3, 4, 5}, 5]'
{1, 2, 3, 4, 5}