Skip to content

Instantly share code, notes, and snippets.

View vikingosegundo's full-sized avatar

Manuel Meyer vikingosegundo

  • Groningen, Netherlands
View GitHub Profile
let t1 = t0.alter(.unfinish)
let t1 = t0.alter(.finish)
let t0 = TodoItem(title:"Get Coffee")
let t1 = t0.alter(.title("Get Coffee — ASAP"))
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
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)
}
import Foundation
extension Int {
func times(_ text: String) -> String {
(0..<self).reduce(""){ e, _ in e + text }
}
}
let digits = [
("I", "V", "X"),
Button { decrease(value:.colortemp,by:10.pt,on:light) }
label: {
Image(systemName:"thermometer.sun")
.foregroundStyle(ctColor(ct:(Double(temperatureValue(of: light)) * 0.8)))
.accessibility(label:Text("decrease color temperature"))
}
private func decrease(value:Light.Value,by dec:Light.Value.Increment, on light:Light) { rootHandler( .lighting(.decrease(value,by:dec,on:light)) ) }
Slider(value: $ct, in: (-500)...(-153)) { _ in
apply(values: .ct(Int(-ct),bri), on: light)
}
private func apply(values:Light.Values,on light:Light) {
rootHandler( .lighting(.apply(.values(values),on:light)) )
}