This file contains hidden or 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 t1 = t0.alter(.unfinish) |
This file contains hidden or 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 t1 = t0.alter(.finish) |
This file contains hidden or 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 t0 = TodoItem(title:"Get Coffee") | |
let t1 = t0.alter(.title("Get Coffee — ASAP")) |
This file contains hidden or 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
struct TodoItem:Identifiable { | |
enum Change { | |
case title (to:String) | |
case due (to:TodoDate) | |
case location(to:Location) | |
case finish | |
case unfinish | |
} | |
// members | |
let id : UUID |
This file contains hidden or 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 romans = (1...100).map { roman(for: $0) } // numerals from ints | |
let ints = romans.map { from(roman: $0) } // ints from numerals | |
(zip(ints, romans)).forEach { x in | |
print(x) | |
} |
This file contains hidden or 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 | |
extension Int { | |
func times(_ text: String) -> String { | |
(0..<self).reduce(""){ e, _ in e + text } | |
} | |
} | |
let digits = [ | |
("I", "V", "X"), |
This file contains hidden or 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 func decrease(value:Light.Value,by dec:Light.Value.Increment, on light:Light) { rootHandler( .lighting(.decrease(value,by:dec,on:light)) ) } |
This file contains hidden or 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
Slider(value: $ct, in: (-500)...(-153)) { _ in | |
apply(values: .ct(Int(-ct),bri), on: light) | |
} |
This file contains hidden or 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 func apply(values:Light.Values,on light:Light) { | |
rootHandler( .lighting(.apply(.values(values),on:light)) ) | |
} |
NewerOlder