Files
swift-mirror/test/Interpreter/functions.swift
Joe Groff 637c4e8171 Fold Interpreter and Interpreter/SIL tests.
There is only SIL. No reason to keep a subdirectory around.

Swift SVN r6029
2013-07-05 23:11:44 +00:00

29 lines
439 B
Swift

// RUN: %swift -i %s | FileCheck %s
func double(x:Int) -> Int {
return x+x
}
func curriedSubtract(x:Int)(y:Int) -> Int {
return x-y
}
func twice(f:(Int) -> Int, x:Int) -> Int {
return f(f(x))
}
// CHECK: 4
println(double(2))
// CHECK: 8
println(double(4))
// CHECK: 12
println(curriedSubtract(16)(4))
// CHECK: 20
println(twice(double, 5))
// CHECK: 7
println(twice({ $0 + 1 }, 5))
// CHECK: 3
println(twice({ |x| x - 1 }, 5))