{
"id": "fn-array-take_while",
"dataComponent": "array",
"heading": {
"title": "take_while",
"badges": ["Array", "PARTIAL"]
},
"synopsis": "Returns the longest prefix of the array for which the predicate returns true. Partial and placeholder usage supported.",
"codeBlocks": [
"extend(\"array\")\n\narr = [2,4,6,7,8]\nsput(array:take_while(x => x % 2 == 0, arr))\n# => [2,4,6]\n\n# Partial usage:\ntw = array:take_while(x => x < 7)\nsput(tw(arr))\n# => [2,4,6]\n\n# Placeholder usage:\np = array:take_while(_, arr)\nsput(p(x => x < 8))\n# => [2,4,6,7]"
],
"notes": [
"First argument: predicate function.",
"Second argument: array.",
"Returns a new array of consecutive elements for which predicate returns true.",
"Partial and placeholder usage supported."
]
}