Took a look at https://developer.apple/swift/ tonight. My version - TopicsExpress



          

Took a look at https://developer.apple/swift/ tonight. My version of hello world is checking to see if a number is prime. I enjoy pythons lazy casting. Swift definitely wants to have a pretty good idea of what type an object is before it does anything with it. Xcode isnt too bad. It is much easier to navigate than some other IDEs Ive seen (cough, VS, cough). Swift is way faster than python, if execution speed is important to you time ./cliprime 3628273133 is prime real 0m0.062s user 0m0.036s sys 0m0.022s // // main.swift // cliprime // // Created by Peter John Hill on 6/28/14. // Copyright (c) 2014 Peter John Hill. All rights reserved. // import Foundation import Cocoa let given_number = 3628273133 func isitprime(given_number: Int) -> Bool { if (given_number < 2) { return false } else if (given_number < 4) { return true } else if ((given_number % 2) == 0) { return false } else { var index:Int index = 5 var floatgiven:Float = Float(given_number) var maxvalue = sqrtf(floatgiven) var maxnumber:Int = Int(maxvalue) while (index
Posted on: Sun, 29 Jun 2014 06:40:48 +0000

Trending Topics



Recently Viewed Topics




© 2015