diff --git a/Learning Swift.playground/Contents.swift b/Learning Swift.playground/Contents.swift new file mode 100644 index 0000000..3f9a482 --- /dev/null +++ b/Learning Swift.playground/Contents.swift @@ -0,0 +1,34 @@ +//: Playground - noun: a place where people can play + +import UIKit + +func swap (inout x: T, inout y: T) { + (x,y) = (y,x); +} + +func flexStrings (x: String = "", y: String = "") -> String { + return x + y +} + +func sumAny (x: Any...) -> String { + return String((x.map({mem in + switch mem { + case 0 as Int, "" as String: + return -10 + case let s as String where Int(s) > 0: + return Int(s)! + case let n as Int: + return n + default: + return 0 + } + + })).reduce(0, combine: +)) +} + +func countFrom (from: Int, to: Int) { + if (from <= to) { + print(from) + countFrom(from + 1, to: to) + } +} \ No newline at end of file diff --git a/Learning Swift.playground/contents.xcplayground b/Learning Swift.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/Learning Swift.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Learning Swift.playground/playground.xcworkspace/contents.xcworkspacedata b/Learning Swift.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Learning Swift.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Learning Swift.playground/playground.xcworkspace/xcuserdata/bge.xcuserdatad/UserInterfaceState.xcuserstate b/Learning Swift.playground/playground.xcworkspace/xcuserdata/bge.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..bf790c7 Binary files /dev/null and b/Learning Swift.playground/playground.xcworkspace/xcuserdata/bge.xcuserdatad/UserInterfaceState.xcuserstate differ