mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 13:24:46 +00:00
chunk function
This commit is contained in:
parent
6146f3b475
commit
cf9af2b5fe
@ -94,6 +94,13 @@ class Collections implements ILib
|
||||
|
||||
// Manipulate list
|
||||
|
||||
$env->set('chunk', new CoreFunc('chunk', 'Divide first argument (sequence) into new sequences with length of second argument (int).', 2, 2,
|
||||
function (Seq $a, int $len) {
|
||||
$chunks = array_chunk($a->getData(), $len);
|
||||
return $a::new(array_map(fn ($b) => $a::new($b), $chunks));
|
||||
}
|
||||
));
|
||||
|
||||
$env->set('push', new CoreFunc('push', 'Push the remaining arguments at the end of the sequence (first argument).', 2, -1,
|
||||
function (Seq $a, ...$b) {
|
||||
$data = $a->getData();
|
||||
|
Loading…
Reference in New Issue
Block a user