計算理論において、ある計算のメカニズムが万能チューリングマシンと同じ計算能力をもつとき、その計算モデルはチューリング完全(チューリングかんぜん、Turing-complete)あるいは計算完備であるという。
- Combinatory Logic(コンビネータ論理)
- コンビネータ計算
- ラムダ計算
Combinatory Logic
// The SwiftUI Lab | |
// Website: https://swiftui-lab.com | |
// Article: https://swiftui-lab.com/alignment-guides | |
import SwiftUI | |
class Model: ObservableObject { | |
@Published var minimumContainer = true | |
@Published var extendedTouchBar = false | |
@Published var twoPhases = true |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
import Combine | |
import Dispatch | |
/// Returns a subscriber that buffers up to `size` values before calling the given `handler`. The | |
/// subscriber will request more values from the upstream publisher once the `completion` closure | |
/// given to the `handler` is called. | |
func subscriber<Output, Failure>(size: Int, handler: @escaping (_ values: [Output], _ completion: @escaping () -> ()) -> ()) -> AnySubscriber<Output, Failure> { |
protocol Action {} | |
struct Reducer<State> { | |
let reduce: (State, Action) -> State | |
} | |
struct Increment: Action {} | |
struct Decrement: Action {} | |
func on<State, A>(_ actionType: A.Type, reduce: @escaping (State, A) -> State) -> Reducer<State> { |
enum Demo { | |
case simple | |
case oneValue(Int) | |
case twoValues(String, Double) | |
case threeValues(one: Int, two: Float, [Int]) | |
} | |
//: # Direct exposition in the enum | |
//: ## Sourcery Template |
// A minimal iOS app set up entirely in code using Objective-C rather than using a storyboard and UIApplicationSceneManifest in the Info.plist. | |
// Last updated for iOS 18. | |
// Swift version: https://gist.github.com/douglashill/b8125f7e2336b6a47461df0d4898f64d | |
@import UIKit; | |
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate> | |
@end | |
@implementation SceneDelegate |
/*: | |
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI | |
The only purpose of this code is to implement those wrappers myself | |
just to understand how they work internally and why they are needed, | |
⚠️ This is not supposed to be a reference implementation nor cover all | |
subtleties of the real Binding and State types. | |
The only purpose of this playground is to show how re-implementing | |
them myself has helped me understand the whole thing better |
import Combine | |
import QuartzCore.CADisplayLink | |
extension CADisplayLink { | |
fileprivate class DisplayLinkWrapper { | |
private var subscriber: AnySubscriber<CADisplayLink, Never> | |
private var displayLink: CADisplayLink? | |
init(runloop: RunLoop, mode: RunLoop.Mode, subscriber: AnySubscriber<CADisplayLink, Never>) { | |
self.subscriber = subscriber |
This is the second article in a series of articles around Rusts new async/await
feature. The first article about interfaces can be found
here.
In this part of the series we want to a look at a mechanism which behaves very
different in Rust than in all other languages which feature async/await
support. This mechanism is Cancellation.