From 7cabc6bd7a8f216faf17c4f14095ee4d7f99569c Mon Sep 17 00:00:00 2001 From: laurent b Date: Sun, 1 Mar 2020 20:47:07 +0100 Subject: [PATCH 1/2] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is shameless, but I thought this would help noobs like me. It is quasi copy and paste your remark on twitter: 'When you run "brisk meh" it creates a new directory called "meh", and puts a project in there. If you go in there and use "swift run" it will run from the command line; if you use "swift build" you'll get a finished binary you can put anywhere'. This did help me a lot so I thought why not put it in there too.. 😅 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6f96dad..137598a 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. From bacb79f6109a7ff58896c76d7b6af97e923a7c4a Mon Sep 17 00:00:00 2001 From: laurent b Date: Sat, 7 Mar 2020 11:23:54 +0100 Subject: [PATCH 2/2] Update Numeric.swift // ------------------------------------------ // How to replicate the ** operator in Swift // --- BriskScript/Sources/Brisk/Numeric.swift | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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))) +}