mirror of
https://github.com/twostraws/Brisk.git
synced 2025-01-03 07:26:27 +03:00
Merge pull request #3 from multitudes/master
Adding '**' operator for exponential
This commit is contained in:
commit
47bac1e184
@ -39,3 +39,25 @@ func /<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
||||
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)))
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ brisk myscriptname
|
||||
|
||||
That will create a new directory called `myscriptname`, copy in all the helper functions, then open it in Xcode ready for you to edit. Using Xcode means you get full code completion, and can run your script by pressing Cmd+R like usual.
|
||||
|
||||
Using `swift run` from that directory, the script will run from the command line; if you use `swift build` you'll get a finished binary you can put anywhere.
|
||||
|
||||
**Warning:** The `brisk` command is easily the most experimental part of this whole package, so please let me know how you get on with it. Ideally it should create open Xcode straight to an editing window saying `print("Hello, Brisk!")`, but let me know if you get something else.
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user