TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | May 2015 |
SPMSupports SPM | ✗ |
Maintained by Rahul Nadella.
The CalculationUtility provides several functions to enable calculation of values easier using explicit casting.
The CalculationUtility contains the following functions: summation, product, factorial, min, max, squared, cubed, and overloaded +,-,*,/,<,> (which are explicitly casted). This utility can make your life with Swift easier when doing calculations between different type (for example: double + int -> double + double(int)).
Swift currently has a type check and requires left and right operand of the same type. When using this utility you will lose type safety when using these operators, which is opposite to Swift design.
Version 1.1 -> Upgrade to iOS 8.3 (Fixed issue with Slice being removed and replaced with ArraySlice)
Version 1.0 -> Design and Implementation of the CalculationUtility
Master -> Only works on iOS 8.3
Add the CalculationUtility to your project. This file can be found in src/CalculationUtility.swift.
var a = 5.0
var b = 2
a + b -> 7.0
a - b -> 3.0
a * b -> 10.0
a / b -> 2.5
a % b -> 1
let lessThanValue = b < a -> true
let greaterThanValue = b > a -> false
var value = 5
value~! = 120
var numericalValues = [4, 2, 5, 120, 500, 1001, 1, 1002]
var minValue = min(numericalValues) -> 1
var maxValue = max(numericalValues) -> 1002
∑([1, 2, 3]) -> 6
sumOf(1, 2, 3) -> 6
∑(array) -> 6
sumOf(array) -> 6
sumOf(array[0...1]) -> 3
∏([2, 3, 4]) -> 24
productOf(2,3,4) -> 24
∏(array) -> 24
productOf(array) -> 24
productOf(array[0...1]) -> 6
squared(3) -> 9
cubed(3) -> 27
MIT License --> A short, permissive software license. Basically, you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source. There are many variations of this license in use.