Swift Custom Operators for Mathematical Notation

Overview

Euler

Build Status License Swift Version

Euler uses custom 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 after Leonhard 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 letters e to denote the base of the natural logarithm & i to denote the imaginary unit, sin & cos for trigonometric functions, and f(x) to denote the function f with argument x.


Example Usage

import Foundation
import Euler
import PlaygroundSupport

𝑒 // 2.718281828459045

¬true // false

3 × 4 // 12

let prime = [2, 3, 5, 7, 11]
let fibonacci = [1, 1, 2, 3, 5, 8, 13]
prime  fibonacci // {2, 3, 5}

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

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

7  9 // true

var f: (Double) -> Double = sin
let g: (Double) -> Double = cos

for x in stride(from: 0, to: 4 * π, by: π / 8) {
    (f  g)(x) // ∿∿∿
}

(f)(π) // -1

Inventory

Mathematical Constants

Logic

Arithmetic

Sets

Sequences

Vectors

Comparison

Calculus

Functions


License

MIT

Contact

Mattt (@mattt)

You might also like...
Swift Matrix Library

Swift Matrix and Machine Learning Library Note: tensorflow/swift and apple/swift-numerics/issues/6 have or will have more complete support for NumPy-l

MRFoundation - A library to complement the Swift Standard Library

MRFoundation MRFoundation is a library to complement the Swift Standard Library.

A cross-platform Swift library for evaluating mathematical expressions at runtime

Introduction What? Why? How? Usage Installation Integration Symbols Variables Operators Functions Arrays Performance Caching Optimization Standard Lib

JSEN (JSON Swift Enum Notation) is a lightweight enum representation of a JSON, written in Swift.

JSEN /ˈdʒeɪsən/ JAY-sən JSEN (JSON Swift Enum Notation) is a lightweight enum representation of a JSON, written in Swift. A JSON, as defined in the EC

Swift library for parsing Extended Backus–Naur Form (EBNF) notation

Gramophone Swift library for parsing Extended Backus–Naur Form (EBNF) notation Integration Swift Package Manager dependencies: [ .package(url: "ht

Infix operators for monadic functions in Swift
Infix operators for monadic functions in Swift

Indecipherable symbols that some people claim have actual meaning. Please see the documentation for installation instructions. What's included? Import

🎯 PredicateKit allows Swift developers to write expressive and type-safe predicates for CoreData using key-paths, comparisons and logical operators, literal values, and functions.
🎯 PredicateKit allows Swift developers to write expressive and type-safe predicates for CoreData using key-paths, comparisons and logical operators, literal values, and functions.

🎯 PredicateKit PredicateKit is an alternative to NSPredicate allowing you to write expressive and type-safe predicates for CoreData using key-paths,

Infix operators for monadic functions in Swift
Infix operators for monadic functions in Swift

Indecipherable symbols that some people claim have actual meaning. Please see the documentation for installation instructions. What's included? Import

AsyncExtensions aims to mimic Swift Combine operators for async sequences.

AsyncExtensions AsyncExtensions provides a collection of operators, async sequences and async streams that mimics Combine behaviour. The purpose is to

A collection of operators and utilities that simplify iOS layout code.

Anchorage A lightweight collection of intuitive operators and utilities that simplify Auto Layout code. Anchorage is built directly on top of the NSLa

ProgrammingCalculator - a simple programmer's calculator with operators like AND, OR
ProgrammingCalculator - a simple programmer's calculator with operators like AND, OR

Programmer's Calculator This is a simple calculator program which implements operators commonly used in discrete logic such as AND, OR, Bit Shifting,

:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion
:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion

ADAPTIVE TAB BAR 'Progressive Reduction' module for adding custom states to Native or Custom UI elements. We specialize in the designing and coding of

Custom-TopBarController - A Custom TopBar Controller With Swift
Custom-TopBarController - A Custom TopBar Controller With Swift

TopBarController Верстка Для IPhone и IPod вертска адаптивная, для IPad frane To

Custom-action-sheet- - Custom action sheet with swift

Custom-action-sheet- Usage let alertController: UIAlertControllerDimmed = UIAler

Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

Custom-Transition - A repo about custom transition between two view controllers

Custom-Transition in SWIFT This is a repo about custom transition between two vi

A Collection of PropertyWrappers to make custom Serialization of Swift Codable Types easy

CodableWrappers Simplified Serialization with Property Wrappers Move your Codable and (En/De)coder customization to annotations! struct YourType: Coda

A Swift library to design custom prompts with a great scope of options to choose from.
A Swift library to design custom prompts with a great scope of options to choose from.

Installation CocoaPods Install with CocoaPods by adding the following to your Podfile: source 'https://github.com/CocoaPods/Specs.git' platform :ios,

Comments
  • `SignedInteger & UnsignedInteger` is probably the wrong bounds

    `SignedInteger & UnsignedInteger` is probably the wrong bounds

    What I assume was meant was one of (the non-existent) P | Q, duplicating the functions for SignedInteger and UnsignedInteger separately, or use BinaryInteger.

    This is because no type does, should, or is semantically permitted to conform to both SignedInteger & UnsignedInteger.

    opened by Dante-Broggi 1
  • Update for Swift 2.0

    Update for Swift 2.0

    This updates Euler for Swift 2.0, converting collection function calls to methods, and lets the function composition operator work on functions with different parameter and return types, so you can compose Double -> Int with Int -> String, yielding a Double -> String function.

    opened by natecook1000 1
Owner
Mattt
Mattt
Arbitrary-precision arithmetic in pure Swift

Overview API Documentation License Requirements and Integration Implementation Notes Full-width multiplication and division primitives Why is there no

null 707 Dec 19, 2022
A collection of functions for statistical calculation written in Swift.

σ (sigma) - statistics library written in Swift This library is a collection of functions that perform statistical calculations in Swift. It can be us

Evgenii Neumerzhitckii 658 Jan 5, 2023
Multi-dimensional Swift math

Upsurge Upsurge implements multi-dimensional data structures and operations. It brings numpy-like operations to Swift. Upsurge no longer supports DSP

Alejandro Isaza 180 Dec 20, 2022
Swift Matrix Library

Swift Matrix and Machine Learning Library Note: tensorflow/swift and apple/swift-numerics/issues/6 have or will have more complete support for NumPy-l

Scott Sievert 591 Sep 5, 2022
Overload +-*/ operator for Swift, make it easier to use (and not so strict)

Easy-Cal-Swift Overview This file is an overloading of +-*/ operator for Swift, to make it easier to use (and not so strict) It can make your life wit

Wei Wang 272 Jun 29, 2022
Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)

Matft Matft is Numpy-like library in Swift. Function name and usage is similar to Numpy. Matft Feature & Usage Declaration MfArray MfType Subscription

null 80 Dec 21, 2022
SwiftMath is a Swift framework providing some useful math constructs and functions

SwiftMath is a Swift framework providing some useful math constructs and functions, like complex numbers, vectors, matrices, quaternions, and polynomials.

Matteo Battaglio 175 Dec 2, 2022
VectorMath is a Swift library for Mac and iOS that implements common 2D and 3D vector and matrix functions

Purpose VectorMath is a Swift library for Mac and iOS that implements common 2D and 3D vector and matrix functions, useful for games or vector-based g

Nick Lockwood 341 Dec 31, 2022
Numeric facilities for Swift

NumericAnnex NumericAnnex supplements the numeric facilities provided in the Swift standard library. Features The exponentiation operator ** and the c

Xiaodi Wu 69 Nov 3, 2022
Math expression parser built with Point•Free's swift-parsing package

swift-math-parser Basic math expression parser built with Point•Free's swift-parsing package. NOTE: currently, this uses a fork of that fixes a parsin

Brad Howes 36 Dec 14, 2022