diff --git a/BriskScript/Sources/Brisk/Numeric.swift b/BriskScript/Sources/Brisk/Numeric.swift index 9e8bbc2..a16966a 100644 --- a/BriskScript/Sources/Brisk/Numeric.swift +++ b/BriskScript/Sources/Brisk/Numeric.swift @@ -39,3 +39,25 @@ func /(lhs: I, rhs: F) -> F { func /(lhs: F, rhs: I) -> F { return lhs / F(rhs) } + +// ------------------------------------------ +// How to replicate the ** operator in Swift +// + +infix operator ** + +func **(lhs: I, rhs: I) -> I { + return I(pow(Double(lhs), Double(rhs))) +} + +func **(lhs: I, rhs: F) -> F { + return F(pow(Double(lhs),Double(rhs))) +} + +func **(lhs: F, rhs: I) -> F { + return F(pow(Double(lhs),Double(rhs))) +} + +func **(lhs: F, rhs: F) -> F { + return F(pow(Double(lhs),Double(rhs))) +} diff --git a/README.md b/README.md index ba10d6d..1a9f1d5 100644 --- a/README.md +++ b/README.md @@ -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.