module

Calcium

Constants

OPERATORS = { "+": { func: ->add(Array(Float64)), precedence: 1, num_args: 2, associativity: :left, prefix: false, }, "-": { func: ->subtract(Array(Float64)), precedence: 1, num_args: 2, associativity: :left, prefix: false, }, "*": { func: ->multiply(Array(Float64)), precedence: 2, num_args: 2, associativity: :left, prefix: false, }, "/": { func: ->divide(Array(Float64)), precedence: 2, num_args: 2, associativity: :left, prefix: false, }, "^": { func: ->power(Array(Float64)), precedence: 3, num_args: 2, associativity: :right, prefix: false, }, "!": { func: ->factorial(Array(Float64)), precedence: 5, num_args: 1, associativity: :left, prefix: false, }, "u-": { func: ->negate(Array(Float64)), precedence: 4, num_args: 1, associativity: :right, prefix: true, }, sin: { func: ->(args : Array(Float64)) do Math.sin(args[0]) end, precedence: 100, num_args: 1, associativity: :left, prefix: false, }, cos: { func: ->(args : Array(Float64)) do Math.cos(args[0]) end, precedence: 100, num_args: 1, associativity: :left, prefix: false, }, tan: { func: ->(args : Array(Float64)) do Math.tan(args[0]) end, precedence: 100, num_args: 1, associativity: :left, prefix: false, }, abs: { func: ->(args : Array(Float64)) do args[0].abs end, precedence: 100, num_args: 1, associativity: :left, prefix: false, }, max: { func: ->(args : Array(Float64)) do args.max end, precedence: 100, num_args: 2, associativity: :left, prefix: false, }, min: { func: ->(args : Array(Float64)) do args.min end, precedence: 100, num_args: 2, associativity: :left, prefix: false, }, }
VERSION = {{ (`shards version \"/tmp/tmp.LpkniC/src/src\"`).chomp.stringify }}

Instance methods

calculate(input)
Source
calculate_postfix(tokens : Array(Token))
Source
format(number)
Source
parse_infix(tokens : Array(Token)) : Array(Token)

Converts an array of tokens from infix to postfix

@param Array(Calcium::Token) tokens @return Array(Calcium::Token)

Source
tokenize(string)
Source

Nested types