Skip to content

Commit

Permalink
Merge pull request #6 from somidmor/main
Browse files Browse the repository at this point in the history
add hyperbolic tokens(sinh, cosh, ...), mode(%) function, sec, csc, cot
  • Loading branch information
bradhowes authored Feb 23, 2024
2 parents dbb5e04 + 3f0dfb7 commit 236a92e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Sources/MathParser/MathParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ final public class MathParser {
*/
public static let defaultUnaryFunctions: UnaryFunctionDict = [
"sin": sin, "asin": asin, "cos": cos, "acos": acos, "tan": tan, "atan": atan,
"log10": log10, "ln": log, "loge": log, "log2": log2, "exp": exp,
"sinh": sinh, "asinh": asinh, "cosh": cosh, "acosh": acosh, "tanh": tanh, "atanh": atanh,
"log": log10, "log10": log10, "ln": log, "loge": log, "log2": log2, "exp": exp,
"ceil": ceil, "floor": floor, "round": round,
"sqrt": sqrt, "": sqrt,
"cbrt": cbrt, // cube root,
"abs": abs,
"sgn": { $0 < 0 ? -1 : $0 > 0 ? 1 : 0 },
"!": { factorial($0) }
"!": { factorial($0) },
"sec": { 1 / cos($0) },
"csc": { 1 / sin($0) },
"cot": { 1 / tan($0) }
]

/**
Expand All @@ -97,7 +101,8 @@ final public class MathParser {
public static let defaultBinaryFunctions: BinaryFunctionDict = [
"atan2": atan2,
"hypot": hypot,
"pow": pow // Redundant since we support x^b expressions
"pow": pow, // Redundant since we support x^b expressions
"mod": { $0.truncatingRemainder(dividingBy: $1) }
]

/// Symbol/variable mapping to use during parsing and perhaps evaluation
Expand Down

0 comments on commit 236a92e

Please sign in to comment.