# encoding: ascii
# api: powershell
# title: TheMathFunction
# description: You need to download and unpack LoreSoft.MathExpressions.dll into your Documents\WindowsPowerShell\Libraries or tweak this module.
# version: 1.0
# type: function
# author: Joel Bennett
# license: CC0
# function: Use-Math
# x-poshcode-id: 2094
# x-archived: 2012-01-08T21:02:24
# x-published: 2012-08-19T11:01:00
#
# Examples:
# C:\PS> math 3 ^ sqrt pi
# 7.00931221713741
# C:\PS> math sin sqrt 3
# 0.987026644990354
# C:\PS> math ‘(42 / 9) * ( cos(.56) ^ 3 ) + Tan 60’
# 3.15828206698
# C:\PS>  (math (2mb) ^ 2)/1gb
# 4096
#
Add-Type -Path (Join-Path (Split-Path $Profile) Libraries\LoreSoft.MathExpressions.dll)
## You can dot-source this in 1.0 after uncommenting the following line, and deleting the first and last lines.
# [Reflection.Assembly]::LoadFrom((Join-Path (Split-Path $Profile) Libraries\LoreSoft.MathExpressions.dll)) | Out-Null

$MathEvaluator = New-Object LoreSoft.MathExpressions.MathEvaluator

Function Use-Math {
   $MathEvaluator.Evaluate( ($args -join " ") )
}

Set-Alias Math Use-Math

Export-ModuleMember -Function * -Alias *
