Take: Difference between revisions

From The K Language Wiki
Content added Content deleted
("Add category")
("Add all appropriate categories to each verb")
Line 19: Line 19:


[[Category:Operator verbs]]
[[Category:Operator verbs]]
[[Category:Verbs]]
[[Category:Primitives]]

Revision as of 03:17, 9 July 2022

Take
a#y

The take primitive takes a elements from a given list y.

Positive a takes elements from the beginning, and negative values will take from the end.

If a > #y(a is greater than y's length), y is repeated to that length.

 3#"abcde"
"abc"

 -3#"abcde"
"cde"

 5#,5
5 5 5 5 5