CSS-Tricks - walk

PHOTO EMBED

Sat Aug 07 2021 19:12:50 GMT+0000 (Coordinated Universal Time)

Saved by @mdcx #scss

/// Apply `$function` with `$args` to each item from `$list`.
/// @author Kitty Giraudel
/// @param {List} $list - List of items
/// @param {String} $function - Function to apply to every item from `$list`
/// @param {Arglist} $args - Extra arguments to pass to `$function`
/// @return {List}
/// @throw There is no `#{$function}` function.
@function walk($list, $function, $args...) {
  @if not function-exists($function) {
    @error "There is no `#{$function}` function.";
  }
  
  @for $i from 1 through length($list) {
    $list: set-nth($list, $i, call($function, nth($list, $i), $args...));
  }
  
  @return $list;
}
content_copyCOPY

https://css-tricks.com/snippets/sass/functional-programming-functions/