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
ken@Nepheli /tmp> clang -Wunused -c x.c | |
x.c:2:19: warning: unused variable 'x' [-Wunused-variable] | |
void f(void) {int x, y;} | |
^ | |
x.c:2:22: warning: unused variable 'y' [-Wunused-variable] | |
void f(void) {int x, y;} | |
^ | |
2 warnings generated. | |
ken@Nepheli /tmp> clang -Wunused -Werror -c x.c | |
x.c:2:19: error: unused variable 'x' [-Werror,-Wunused-variable] |
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
let bricks : Array<UIView!> = { | |
var bricks = Array<UIView!>(count:brickCount, repeatedValue: nil) | |
for i in 0..brickCount { | |
let brick = UIView() | |
brick.backgroundColor = UIColor.blueColor() | |
brick.layer.borderColor = UIColor.greenColor().CGColor | |
brick.layer.borderWidth = 1.0 | |
bricks[i] = brick | |
} | |
return bricks |
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
func myAnd(lhs : Bool, rhs : @auto_closure () -> Bool) -> Bool { | |
if lhs { | |
return rhs() | |
} else { | |
return false | |
} | |
} | |
func logAndBool(val : Bool) -> Bool { | |
println("evaluating and returning \(val)!") |
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
func forAllCombinations<T>(r1 : Range<T>, r2 : Range<T>, body : (T, T) -> ()) { | |
for i in r1 { | |
for j in r2 { | |
body(i, j) | |
} | |
} | |
} | |
forAllCombinations(0..3, 0..5) { | |
(i, j) in |
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
func takeThree(i : Int, j : Int, k : Int) { | |
println("yus") | |
} | |
let arg = (1,2,3) | |
takeThree(arg) |
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
#!/usr/bin/xcrun swift -i | |
func takeThree(i : Int, j : Int, k : Int) { | |
println("yus") | |
} | |
let arg = (1,2,3) | |
takeThree(arg) |
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
#!/usr/bin/xcrun swift -i | |
func ambiguous( f : Any...) { | |
for i in f { | |
println("\(i)") | |
} | |
} | |
let arg = (1,2) | |
ambiguous(arg) |
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 | |
var d1 = Dictionary<String, String>() | |
d1["foo"] = "hi" | |
d1["foo"] = nil // this removes the entry from the dict | |
println("\(d1)") // prints [:] | |
var d2 = Dictionary<String, 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
NSImage *pdfImage = [[NSImage alloc] initWithContentsOfFile:@"/Applications/Utilities/Disk Utility.app/Contents/Frameworks/DUSupport.framework/Versions/A/Resources/key.pdf"]; | |
CGSize desiredSize = CGSizeMake(300,300); | |
NSColorSpace *desiredColorspace = [NSColorSpace sRGBColorSpace]; | |
CGRect bounds = { CGPointZero, desiredSize }; | |
// if you'd rather give size as a scale factor from the PDF's logical "size" (which isn't in pixels), could use NSImageHintCTM instead and pass NULL for proposedRect | |
CGImageRef rasterizedIm = [pdfImage CGImageForProposedRect:&bounds context:nil hints:@{ kCIContextOutputColorSpace : (id)[desiredColorspace CGColorSpace], NSImageHintCTM : [NSAffineTransform transform] }]; | |
CGImageDestinationRef idst = CGImageDestinationCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:@"/tmp/output.png"], kUTTypePNG, 1, NULL); |
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
(define (cons a b) | |
(define (dispatch msg) | |
(cond ((= msg 0) a) | |
((= msg 1) b))) | |
dispatch) | |
(define (car cell) | |
(cell 0)) | |
(define (cdr cell) |
OlderNewer