module Calcium

Extended Modules

Defined in:

calcium.cr
calcium/calculate.cr
calcium/exceptions.cr
calcium/formatting.cr
calcium/operators.cr
calcium/parsing.cr
calcium/tokens.cr

Constant Summary

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 \"/srv/crystaldoc.info/github-adoxography-calcium-master/src\"`).chomp.stringify }}

Instance Method Summary

Instance Method Detail

def calculate(input) #

[View source]
def calculate_postfix(tokens : Array(Token)) #

[View source]
def format(number) #

[View source]
def 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)


[View source]
def tokenize(string) #

[View source]