mirror of
https://github.com/twostraws/Brisk.git
synced 2026-10-20 05:18:24 +02:00
for the regex now the functions name is :
func captureGroups(from regexPattern: String) -> [String]? {
and fixing some spaces and one typo.
I am sorry, I am quite new to this. Hope I did not change too much at once. Thank you
64 lines
1.5 KiB
Swift
64 lines
1.5 KiB
Swift
//
|
|
// Comparable.swift
|
|
// Terminal
|
|
//
|
|
// Created by Paul Hudson on 20/02/2020.
|
|
// Copyright © 2020 Hacking with Swift. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
func +<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
|
return F(lhs) + rhs
|
|
}
|
|
|
|
func +<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: F, rhs: I) -> F {
|
|
return lhs + F(rhs)
|
|
}
|
|
|
|
func -<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
|
return F(lhs) - rhs
|
|
}
|
|
|
|
func -<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: F, rhs: I) -> F {
|
|
return lhs - F(rhs)
|
|
}
|
|
|
|
func *<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
|
return F(lhs) * rhs
|
|
}
|
|
|
|
func *<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: F, rhs: I) -> F {
|
|
return lhs * F(rhs)
|
|
}
|
|
|
|
func /<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
|
return F(lhs) / rhs
|
|
}
|
|
|
|
func /<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: F, rhs: I) -> F {
|
|
return lhs / F(rhs)
|
|
}
|
|
|
|
// ------------------------------------------
|
|
// How to replicate the ** operator in Swift
|
|
//
|
|
|
|
infix operator **
|
|
|
|
func **<I: BinaryInteger>(lhs: I, rhs: I) -> I {
|
|
return I(pow(Double(lhs), Double(rhs)))
|
|
}
|
|
|
|
func **<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
|
return F(pow(Double(lhs), Double(rhs)))
|
|
}
|
|
|
|
func **<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: F, rhs: I) -> F {
|
|
return F(pow(Double(lhs), Double(rhs)))
|
|
}
|
|
|
|
func **<F: BinaryFloatingPoint>(lhs: F, rhs: F) -> F {
|
|
return F(pow(Double(lhs), Double(rhs)))
|
|
}
|