Llm.flat: def of bend-kit-llm@0.13.0.1 Import: import bend-kit-llm@0.13.0.1/llm.bend as Llm Lines 122-144 of bend-kit-llm@0.13.0.1/llm.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-llm@0.13.0.1/llm.bend&start_line=122&end_line=144 import Base import bend-kit-json@0.7.0.0/json.bend as Json import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes import bend-kit-encoding@0.5.0.0/encoding.bend as Enc # The leaves under the stack's values, last first. f: at least the values left. def flat(f: Nat, stack: List<&1, String & Json.Val>, acc: List<&2, Leaf>) -> List<&2, Leaf>: match f: case 0n: acc case 1n+g: match stack: case Nil{}: acc case Con{(p, v), t}: match v: case Json.Null{}: flat(g, t, acc) case Json.Flag{on}: flat(g, t, Con{Leaf{p, Bool.pick(String, on, "true", "false")}, acc}) case Json.Num{s}: flat(g, t, Con{Leaf{p, Bytes.to_string(s)}, acc}) case Json.Str{s}: flat(g, t, Con{Leaf{p, Enc.utf8.decode(s)}, acc}) case Json.Arr{xs}: flat(g, push.arr(xs, p, 0, t), acc) case Json.Obj{kvs}: flat(g, push.obj(kvs, p, t), acc) Uses (12): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=bend-kit-bytes@0.3.3.0/bytes.bend&name=to_string https://jend.leeeet.dev/definition.txt?path=bend-kit-encoding@0.5.0.0/encoding.bend&name=utf8.decode https://jend.leeeet.dev/definition.txt?path=bend-kit-json@0.7.0.0/json.bend&name=Val https://jend.leeeet.dev/definition.txt?path=bend-kit-llm@0.13.0.1/llm.bend&name=Leaf https://jend.leeeet.dev/definition.txt?path=bend-kit-llm@0.13.0.1/llm.bend&name=push.arr https://jend.leeeet.dev/definition.txt?path=bend-kit-llm@0.13.0.1/llm.bend&name=push.obj