-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Hello!
A sl-reduce() function would be great! Check this:
@function reduce($list, $callback, $accumulator: 0){
@if(not function-exists($callback)){
@warn "Cannot find callback '" + inspect($callback) + "'.";
@return $accumulator;
}@else{
@each $item in $list {
$accumulator: call($callback, $accumulator, $item);
}
@return $accumulator;
}
}And a callback:
@function add($a, $b){
@return $a + $b;
}Could be used like this:
@debug reduce((1 2 3), add); // yields 6
@debug reduce(("hello" "world"), add, ""); // yields "hello world"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels