Skip to content

Instantly share code, notes, and snippets.

View Abizern's full-sized avatar
🎧
Working from home

Abizer Nasir Abizern

🎧
Working from home
View GitHub Profile
@sdarlington
sdarlington / fizzbuzz.swift
Last active August 29, 2015 14:03
FizzBuzz
import Foundation
func genericFizzBuzz<T> (number:T, tests:Array<(T)->String?>) -> String {
// Run each of the defined test replacements
let out = tests.map { t in t(number) }
// convert the nil's to empty strings
.map { v in v ?? "" }
// Concatenate all the replacements together
.reduce("", combine: +)