Tweetable Swift (@140Swift) header
Tweetable Swift (@140Swift) profile picture

Swift nuggets in 140 Extended Grapheme Cluster Literals or fewer.

Joined November 2014
Time's up! Traveling today, so the results will come this evening.
1
☛ Tweetable Swift Challenge #3: grouping strings! More information here: 140swift.tumblr.com/post/105…
2
4
3
☞ The 2nd weekly Tweetable Swift challenge starts… now! Prime Factorization - rules and more info: 140swift.tumblr.com/post/104… #SwiftLang #Swift
5
1
1
Tweetable Swift retweeted
Swift's acceptance of unicode identifiers sure is fun: mikeash.com/tmp/screenshot_C…
4
4
5
Forgot mine! 😳 reduce(s, (true, "")) { (!$0.0, $0.0 ? "\($0.1)\($1)" : "\(dropLast($0.1))\($1)\(last($0.1)!)" ) }.1 #SwiftLang
2
☞ Announcing the 1st weekly Tweetable Swift challenge! String Twiddling - rules and more info: 140swift.tumblr.com/post/104… #SwiftLang #Swift
3
3
2
join("\r",map(Array(1...n), { i -> String in if i%3==0 { return i%5==0 ? "FizzBuzz" : "Fizz" } else { return i%5==0 ? "Buzz" : "\(i)" } }))
Tweetable Swift retweeted
extension Array { func nonnilmap<X>(transform:(T->X?))->[X] { return (transform).filter{ $0 != nil }.map { $0! as X } } } #swift
2
1
2
let luhn=0==reduce(reverse(map(💳){"\($0)".toInt()!}),[(false,0)]){$0+[(!$0.last!.0,$0.last!.0 ? $1*2/10+$1*2%10:$1)]}.reduce(0){$0+$1.1}%10
1
1
func reduceRight<T, U>(s: [T], i: U, c: (U, T) -> U) -> U { return reduce(lazy(s).reverse(), i) { c($0, $1) } } #Swift #SwiftLang
2
3