@function ballistic-chain($input, $functions...) {
  $result: $input;

  @each $function in $functions {
    $name: null;
    $args: ();

    @for $index from 1 through length($function) {
      $item: nth($function, $index);

      @if $index == 1 {
        $name: $item;
      } @else {
        $args: append($args, $item);
      }
    }

    $str-length: str-length($name);

    @if str-slice($name, $str-length, $str-length) == "!" {
      $result: call(str-slice($name, 1, $str-length - 1), $result...);
    } @else {
      $result: call($name, $result, $args...);
    }
  }

  @return $result;
}
