Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.
/ Euler Public archive

Swift Custom Operators for Mathematical Notation

License

Notifications You must be signed in to change notification settings

mattt/Euler

Repository files navigation

Euler

Build Status License Swift Version

Euler usescustom operators in the "Math Symbols"character set to implement functions using traditional mathematical notation.

Please keep in mind that this is not intended or recommended for production.Custom operators of any breed are ripe for misuse and abuse, and should be used with as much care and caution as you would something like method swizzling or complex macros.

Euler is much better-suited to a Playground, where it could be used for teaching and learning logic and mathematics using a more vernacular notation.

Euler is named afterLeonhard Euler,the Swiss mathematician credited for the popularization of modern mathematical notation such as the Greek lettersΣfor summation &πfor the ratio of a circle's circumference to its diameter, the letterseto denote the base of the natural logarithm &ito denote the imaginary unit,sin&cosfor trigonometric functions, andf(x)to denote the functionfwith argumentx.


Example Usage

import Foundation
import Euler
import PlaygroundSupport

𝑒// 2.718281828459045

¬true// false

3×4// 12

letprime=[2,3,5,7,11]
letfibonacci=[1,1,2,3,5,8,13]
primefibonacci// {2, 3, 5}

[1,2,3,4,5]// 15

[1,2][3,4]// 11

79// true

varf:(Double)->Double=sin
letg:(Double)->Double=cos

forxinstride(from:0,to:4*π,by:π/8){
(fg)(x)// ∿∿∿
}

(f)(π)// -1

Inventory

Mathematical Constants

Logic

Arithmetic

Sets

Sequences

Vectors

Comparison

Calculus

Functions


License

MIT

Contact

Mattt (@mattt)