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
// | |
// APAspectFitImageView.h | |
// autolayout | |
// | |
// Created by Antol Peshkov on 16.10.14. | |
// Copyright (c) 2014 Antol Peshkov. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> |
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
/// Playground - noun: a place where people can play | |
/// Church-Turing clan ain’t nothing to func with. | |
/// Church encoding is a means of representing data and operators in the lambda | |
/// calculus. In Swift, this means restricting functions to their fully curried | |
/// forms; returning blocks wherever possible. Church Encoding of the natural | |
/// numbers is the most well-known form of encoding, but the lambda calculus is | |
/// expressive enough to represent booleans, conditionals, pairs, and lists as | |
/// well. This file is an exploration of all 4 representations mentioned. |
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 XCTest | |
import Foundation | |
// Generates values from a closure that invokes a "yield" function | |
struct YieldGenerator<T>: Generator { | |
var yieldedValues = Array<T>() | |
var index = 0 | |
mutating func yield(value: T) { | |
yieldedValues.append(value) |
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
/***************************************************************************** | |
* Copyright (c) 2011 Kenneth Waters | |
* | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a | |
* copy of this software and associated documentation files (the "Software"), | |
* to deal in the Software without restriction, including without limitation | |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
* and/or sell copies of the Software, and to permit persons to whom the | |
* Software is furnished to do so, subject to the following conditions: |
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
// | |
// CollectionViewDataSource.swift | |
// Khan Academy | |
// | |
// Created by Andy Matuschak on 10/14/14. | |
// Copyright (c) 2014 Khan Academy. All rights reserved. | |
// | |
import UIKit |
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
// Playground - noun: a place where people can play | |
protocol ℕ { | |
static func construct() -> Self | |
static var value : UInt { get } | |
} | |
struct Zero : ℕ { | |
static func construct() -> Zero { | |
return Zero() |
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
public func unsafeCoerce<A, B>(_ x : A) -> B { | |
return unsafeBitCast(x, to: B.self) | |
} | |
func Y<A>(_ f : @escaping (A) -> A) -> A { | |
return { (x : @escaping (A) -> A) in | |
return f((x(unsafeCoerce(x)))) | |
}({ (x : A) -> A in | |
let fn : (A) -> A = unsafeCoerce(x) | |
return f(fn(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
// Playground - noun: a place where people can play | |
public func id<A>(x : A) -> A { | |
return x | |
} | |
public func error<A>(x : String) -> A { | |
assert(false, 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
private class MyArrayBuffer<Element>: ManagedBuffer<Int,Element> { | |
func clone() -> MyArrayBuffer<Element> { | |
return self.withUnsafeMutablePointerToElements { elements -> MyArrayBuffer<Element> in | |
return MyArrayBuffer<Element>.create(self.allocatedElementCount) { newBuf in | |
newBuf.withUnsafeMutablePointerToElements { newElems->Void in | |
newElems.initializeFrom(elements, count: self.value) | |
} | |
return self.value |
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
/*<?php | |
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s", | |
//\u000A\u002F\u002A | |
class PhpJava { | |
static function main() { | |
echo(//\u000A\u002A\u002F | |
"Hello World!"); | |
}} | |
//\u000A\u002F\u002A | |
PhpJava::main(); |