def elements.kinds

gralha-xml-doc@0.1.0.1 · xml.bend:463

import gralha-xml-doc@0.1.0.1/xml.bend as Xml
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U

463# The number of elements in a forest, the roots included.
464# Which of four element names the tree holds, as bits: 1 image, 2 use, 4 text, 8 style.
465def elements.kinds(xs: List<&2, Element>, +acc: U32) -> U32:
466  match xs:
467    case Nil{}: acc
468    case Con{Element{name, attrs, kids, text}, rest}:
469      +n = name
470      elements.kinds(rest, elements.kinds(kids, U32.or(acc, U.choose(U32, U.string.equal(n, "image"), 1,
471        U.choose(U32, U.string.equal(n, "use"), 2, U.choose(U32, U.string.equal(n, "text"), 4, U.choose(U32, U.string.equal(n, "style"), 8, 0)))))))

Uses (6)

Used by (2)