### ----------------------------------------------------
### -- Red
### -- Licenses: Artistic-2.0
### -- Authors: Fernando Correa de Oliveira
### -- File: lib/Red/ResultSeqMethods.rakumod
### ----------------------------------------------------
use Red::AST::Function;
unit role Red::ResultSeqMethods;

sub __RED_OPERATOR_LOADED__ { True }

method !agg(Str $func, &block) {
  my $*RED-FALLBACK = False;
  self.map({
    my @args = block $_;
    Red::AST::Function.new: :$func, :@args
  }).ast: :sub-select
}

method min(&block) {
  self!agg("min", &block)
}

method max(&block) {
  self!agg("max", &block)
}

method sum(&block) {
  self!agg("sum", &block)
}


