Documentation
¶
Index ¶
- Constants
- func CompoundInterest(principal, rate float64, timesPerYear, years int) float64
- func FormatDollars(f float64) string
- func MonthlyLoanPayment(amount, rate float64, years int) float64
- func PadDecimal(s string, precision int) string
- func PadRight(str, pad string, length int) string
- func PresentValue(desiredAmount, rate float64, timesPerYear, years int) float64
- func PrintlnDollars(f float64) (int, error)
- func Round(num float64, precision int) float64
- func Sigma(lower, upper int, fn SummandFunc) (sum float64)
- func SimpleMovingAverage(in []float64, num int) (out []float64, err error)
- func SumFloat64(data []float64) (sum float64)
- func SumInt(data []int) (sum int)
- func SumInt64(data []int64) (sum int64)
- func SummandN(n int) float64
- func SummandNSquared(n int) float64
- func TotalLoanPayment(amount, rate float64, years int) float64
- type SummandFunc
Constants ¶
const ( PeriodAnnual = 1 PeriodSemiAnnual = 2 PeriodQuarterly = 4 PeriodMonthly = 12 PeriodDaily = 365 )
Period* constants are used as "times per year" values.
Variables ¶
This section is empty.
Functions ¶
func CompoundInterest ¶
CompoundInterest is interest calculated on the initial principal inclusive of the accumulated interest over a period of time
func FormatDollars ¶
FormatDollars format a float to a humanized dollar amount.
func MonthlyLoanPayment ¶
MonthlyLoanPayment returns the monthy loan payment.
func PadDecimal ¶
PadDecimal pads decimals with "0" to two decimal places.
func PresentValue ¶
PresentValue calculates the present day value of an amount that is received at a future date.
func PrintlnDollars ¶
PrintlnDollars prints a humanized dollar amount to STDOUT with a trailing newline character.
func Round ¶
Round rounds a float64 to the specified precision, i.e. the number of digits after the decimal point.
func Sigma ¶
func Sigma(lower, upper int, fn SummandFunc) (sum float64)
Sigma sums up values as represented in Σ notation.
Assuming that n is the index of summation, lower is the lower limit of n, upper is the upper limit of n, and fn is the summand being summed up.
func SimpleMovingAverage ¶
SimpleMovingAverage calculates a moving average for a float64 slice.
func SumFloat64 ¶
SumFloat64 sums the values in a float64 slice.
func SummandNSquared ¶
SummandNSquared sums up n to the power of 2.
func TotalLoanPayment ¶
TotalLoanPayment returns the total loan payment over the whole term.
Types ¶
type SummandFunc ¶
SummandFunc is a function definition for a summand in Σ notation.