This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class Espresso : NSObject { | |
internal var running: Bool = false | |
var currDownload: Int64 = -1 | |
internal func download(urlString: String) { | |
let config = NSURLSessionConfiguration.default() | |
let session = NSURLSession(configuration: config, delegate: self, delegateQueue: nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
//Simple upload example without a delegate | |
public class UploadTask : NSObject { | |
public var uploading = false | |
let filePath: String | |
let fileName: String | |
var task: NSURLSessionDataTask! = nil | |
var session: NSURLSession! = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- sum of first N integers | |
sumtorial :: Integer -> Integer | |
sumtorial 0 = 0 | |
sumtorial n = n + sumtorial (n-1) | |
-- the abs function using guards | |
mabs :: Integer -> Integer | |
mabs x | |
| x == 0 = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def abs(x: Double) = if (x > 0) x else -x | |
def isGoodEnough(guess: Double, x: Double) = abs(guess * guess - x)/x < 0.0000001 | |
def improve(guess: Double, x: Double) = (guess + x/guess)/2 | |
def newtonsMethod(guess: Double, x: Double): Double = { | |
if (isGoodEnough(guess,x)) guess | |
else newtonsMethod(improve(guess, x), x) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum(x: Int, y: Int) = { | |
print("In sum\n") | |
x + y | |
} | |
def square(x: Int) = { | |
print("In square\n") | |
x * x | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- counting the number of vowels in a string | |
import Data.Char | |
isVowel::Char->Bool | |
isVowel c | |
| u == 'A' || u == 'E' = True | |
| u == 'I' || u == 'O' = True | |
| u == 'U' = True | |
| otherwise = False | |
where u = toUpper c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% My first Erlang program | |
-module(first). | |
-export([double/1,mul/2,areaOfTriangle/3,productOfList/1,squaredList/1]). | |
-export([factorial/1, aNd/2, xOr/2, oR/2, nOr/1,howMany/3, fibonacci/1, fib/1]). | |
-export([fact/1]). | |
mul(X,Y) -> | |
X*Y. | |
double(X) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class DataTask: NSObject { | |
public var downloading = false | |
let baseURL = "https://restcountries.eu/rest/v1/name/" | |
public var capital = "unknown" | |
var task: NSURLSessionDataTask! = nil | |
var session: NSURLSession! = nil | |
private var country: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class Test : NSObject { | |
public init?(x: Bool) { | |
guard x == true else { return nil } | |
} | |
public override var description: String { | |
return "test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class Test : NSObject { | |
public override var description: String { | |
return "test" | |
} | |
} | |
print(Test()) |
OlderNewer