Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dvanwinkle on github.
  • I am danvw (https://keybase.io/danvw) on keybase.
  • I have a public key ASATjycv9grAu2JLy7i-bBCd9dy7tNsgr9n0OtRszWnlTwo

To claim this, I am signing this object:

code

func testFunction() -> NSString {
}
public void TestFunction()
{
@dvanwinkle
dvanwinkle / memo.swift
Last active October 16, 2015 19:03
Memoization in Swift
import Foundation
func perf<T, U>(f: T -> U) -> T -> (NSTimeInterval, U) {
return {
(a: T) -> (NSTimeInterval, U) in
let start = NSDate()
let result = f(a)
return (NSDate().timeIntervalSinceDate(start), result)
@dvanwinkle
dvanwinkle / CustomWhileSwift
Created June 15, 2015 21:39
Create Custom While Loop in Swift
func while1(@autoclosure c: () -> Bool, body: () -> ()) {
println("here")
if c() {
body()
while1(c, body)
}
}
var counter = 0
while1(counter < 10) {