This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Protocol defines a mandatory function | |
| protocol FooType { | |
| func introduce() -> Void | |
| } | |
| // Default implementation of the protocol requirement | |
| extension FooType { | |
| func introduce() { | |
| print("This is the FooType") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Created by Piotr Gorzelany on 23/09/15. | |
| // Copyright © 2015 Piotr Gorzelany. All rights reserved. | |
| // | |
| /** Contains a collection of methods and data types needed to perform a random walk simulation of a stock price. | |
| The random walk is based on an asumption of a normal distribution of the stock daily rates of return. */ | |
| public struct SPSimulation { | |
| /** Contains stock information needed to perform a simulation */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Used for piping the results of consecutive functions | |
| */ | |
| infix operator |> { associativity left precedence 140 } | |
| func |> <I, O>(input: I, transform: (I) -> O) -> O { | |
| return transform(input) | |
| } | |
| let root = 4 + 3 * 4 |> {Double($0)} |> sqrt | |
| print(root) // 4 |