Sha256: 21ce6e2e8afa566ef9974cf31f283147d6443a253b4c977732f31502c3743a4f

Contents?: true

Size: 364 Bytes

Versions: 15

Compression:

Stored size: 364 Bytes

Contents

require_relative '../function'

Dentaku::AST::Function.register(:sum, :numeric, ->(*args) {
  if args.empty?
    raise Dentaku::ArgumentError.for(
        :too_few_arguments,
        function_name: 'SUM()', at_least: 1, given: 0
    ), 'SUM() requires at least one argument'
  end

  args.flatten.map { |arg| Dentaku::AST::Function.numeric(arg) }.reduce(0, :+)
})

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
dentaku-3.5.4 lib/dentaku/ast/functions/sum.rb
dentaku-3.5.3 lib/dentaku/ast/functions/sum.rb
dentaku-3.5.2 lib/dentaku/ast/functions/sum.rb
dentaku_zevo-3.5.2 lib/dentaku/ast/functions/sum.rb
dentaku-3.5.1 lib/dentaku/ast/functions/sum.rb
dentaku-3.5.0 lib/dentaku/ast/functions/sum.rb
dentaku-3.4.2 lib/dentaku/ast/functions/sum.rb
dentaku-3.3.4 lib/dentaku/ast/functions/sum.rb
dentaku-3.3.3 lib/dentaku/ast/functions/sum.rb
dentaku-3.3.2 lib/dentaku/ast/functions/sum.rb
dentaku-3.3.1 lib/dentaku/ast/functions/sum.rb
dentaku-3.3.0 lib/dentaku/ast/functions/sum.rb
dentaku-3.2.1 lib/dentaku/ast/functions/sum.rb
dentaku-3.2.0 lib/dentaku/ast/functions/sum.rb
dentaku-3.1.0 lib/dentaku/ast/functions/sum.rb