mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
22 lines
490 B
Swift
22 lines
490 B
Swift
// RUN: %target-swift-frontend -emit-ir %s -disable-availability-checking
|
|
|
|
public protocol Signal {
|
|
mutating func process() -> Float
|
|
}
|
|
|
|
public struct Mixer<each Source: Signal> {
|
|
public var sources: (repeat each Source)
|
|
|
|
public mutating func process() -> Float {
|
|
var result: Float = 0
|
|
|
|
self.sources = (repeat ({
|
|
var signal = $0
|
|
result += signal.process()
|
|
return signal
|
|
}(each sources)))
|
|
|
|
return result
|
|
}
|
|
}
|