Css.css.nth.formula: def of gralha-css-style@0.1.0.1 Import: import gralha-css-style@0.1.0.1/css.bend as Css Lines 144-153 of gralha-css-style@0.1.0.1/css.bend: https://jend.leeeet.dev/read.txt?path=gralha-css-style@0.1.0.1/css.bend&start_line=144&end_line=153 import Base import gralha-text-scan@0.1.0.1/scan.bend as U def css.nth.formula(scan: U.Scan, +index: U32) -> Bool: U.Scan{h, t} = scan +head = h +tail = t +a = U.choose(F32, U.string.equal(head, "") || U.string.equal(head, "+"), 1.0, U.choose(F32, U.string.equal(head, "-"), F32.neg(1.0), U.scalar(head, 0.0))) +b = U.scalar(U.drop(tail, "n"), 0.0) +difference = (U32.to_f32(index) - b : F32) +n = (difference / a : F32) U.branch(Bool, U.string.equal(tail, ""), _ => F32.is_eq(U32.to_f32(index), U.scalar(head, F32.neg(1.0))), _ => U.choose(Bool, F32.is_eq(a, 0.0), F32.is_eq(difference, 0.0), F32.is_ge(n, 0.0) && F32.is_eq(n, F32.floor(n)))) Uses (18): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.floor https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.is_ge https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.neg https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_f32 https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=Scan https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=branch https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=choose https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=drop https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=scalar https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=string.equal