Consider the Following

Van Simmons

|

3 min read
A sunset that makes the shape of the Swift logo

Consider the Following:
func doubler(_ anInt: Int) -> String {
    "    \(anInt * 2)    "
}
extension String {
    init(doubler anInt: Int) {
        self = "    \(anInt * 2)    "
    }
}

extension Int {
    var doubler: String {
        let anInt = self
        return "    \(anInt * 2)    "
    }
}

"    \(anInt * 2)    "

One of the distinguishing features of functional programming is the widespread use of combinators to construct programs. A combinator is a function which builds program fragments from program fragments; in a sense the programmer using combinators constructs much of the desired program automatically, rather than writing every detail by hand.

extension String {
    init(doublerF anInt: Int) {
        self = Playground.doubler(anInt)
    }
}

extension Int {
    var doublerF: String {
        Playground.doubler(self)
    }
}
Newsletter Form
  • Where the future is going: sniffing out all of Apple’s clues
    Where the future is going: sniffing out all of Apple’s clues
    See more: Where the future is going: sniffing out all of Apple’s clues
    Small orange arrow symbol
  • Consider the Following – Part 2
    Consider the Following – Part 2
    See more: Consider the Following – Part 2
    Small orange arrow symbol
Abstract graffiti-style artwork with vivid colors and dynamic shapes.
Simple Form

Connect with our team.

Error

An error has occured, please try again.

Try again