Skip to content

Commit 32b358b

Browse files
committed
DCresolve
1 parent f47b809 commit 32b358b

File tree

3 files changed

+99
-6
lines changed

3 files changed

+99
-6
lines changed

src/lib/Co.ts

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ex,C_,i_,o_,VA_ip,detect_type} from '$lib/St'
1+
import {ex,C_,i_,o_,VA_ip,detect_type,inlace,TheC,TheA} from '$lib/St'
22
//#region toCon a dumper for the A** tree
33
export function toCon (d) {
44
if (d.t == null) d.t = 'toCon'
@@ -49,18 +49,109 @@ function toCon_resolve (d) {
4949
let names = d.resolving.map(
5050
d => d.t + (d.C.c.Cont && d.C.c.Cont.sc.Ct ? ':'+d.C.c.Cont.sc.Ct : '')
5151
)
52-
console.log("seen "+d.t+": "+names.join("\t"))
52+
//console.log("seen "+d.t+": "+names.join("\t"))
53+
54+
let C = d.C
55+
let D = d.D
5356

57+
DCresolve({D,C,til:C => C.c.pi == 'Con'})
58+
// export to d.D what they (Con//Con) resolved to
59+
d.resolving.map(d => {
60+
d.D = d.C.y.D
61+
})
5462

63+
if (C.t == 'toCon') console.log("Given:\n"+threelevelprint(C))
5564
}
5665

57-
58-
5966
// now we have d.resolving[d+]
6067
for (let dd of d.resolving) {
6168
toCon_resolve(dd)
6269
}
6370
}
71+
72+
// the q pile visits all C**, wrt D**
73+
// including C between those in the d pile (which are only the -Con)
74+
function DCresolve (c) {
75+
inlace(c.C,{
76+
all:(C,q) => {
77+
if (q.d == 0) {
78+
// d.D -> C.y.D, a given fact
79+
// given from resolving or simply an other branch (eg last time of toCon)
80+
C.y.D = c.D
81+
}
82+
else if (c.til) {
83+
if (c.til(C,q)) q.not = 1
84+
}
85+
},
86+
climbs:(C,q,N) => {
87+
let D = C.y.D
88+
if (!D) return C.c.el = 2
89+
// D options (past), C given
90+
let Dtz = i_tz(o_(D))
91+
let Ctz = i_tz(N)
92+
// have all t in Dtz
93+
for (let t in Ctz) {
94+
Dtz[t] ||= []
95+
}
96+
for (let t in Dtz) {
97+
let Dz = Dtz[t] || []
98+
let Cz = Ctz[t] || []
99+
let Do = Dz.shift()
100+
let Co = Cz.shift()
101+
if (Do && Co) {
102+
// continuation
103+
Co.y.D = Do
104+
}
105+
else if (Co) {
106+
// coming - it will have no .y.D
107+
// so the rest of q will just C.c.el = 2 everything
108+
}
109+
else if (Do) {
110+
// going - tell most recent still-present thing
111+
C.c.removals ||= []
112+
C.c.removals.push(Do)
113+
}
114+
!Dz.length && delete Dtz[t]
115+
!Cz.length && delete Ctz[t]
116+
}
117+
Object.keys(Dtz).length && console.log("Dtz left: "+Object.keys(Dtz).join(','))
118+
Object.keys(Ctz).length && console.log("Ctz left: "+Object.keys(Ctz).join(','))
119+
}
120+
})
121+
}
122+
// indexes a list of C by their .t
123+
function i_tz (N) {
124+
let tz = {}
125+
for (let C of N) {
126+
let t = C.t
127+
tz[t] ||= []
128+
tz[t].push(C)
129+
}
130+
return tz
131+
}
132+
function threelevelprint (C) {
133+
if (!C) return "null"
134+
let N = []
135+
let sip = C => C.c.ip ? C.c.ip.join('.') : ''
136+
inlace(C,{all:(C,d) => {
137+
let sipdom = d.up && sip(d.up.s)
138+
let sipsay = sip(C)
139+
if (sipsay && sipdom && sipsay.startsWith(sipdom)) sipsay = sipsay.slice(sipdom.length)
140+
if (C.c.removals) {
141+
sipsay += " --"+C.c.removals.map(C => C.t).join(',')
142+
}
143+
let scsay = C.sc.Ct ? "%Ct="+C.sc.Ct : ''
144+
if (C.y.D) scsay += '%D'
145+
N.push(
146+
new Array(d.d).fill(' ').join('')
147+
+
148+
C.t+"\t-"+C.c.pi+"\t"+sipsay+"\t"+scsay
149+
)
150+
if (d.d > 2) return 1
151+
}})
152+
return N.join("\n")
153+
}
154+
64155
// defines an adder of d.C or its C.c.$pi=C/*
65156
function DCpartor (nodepi) {
66157
// arrow functions don't provide their own this binding

src/lib/pi/Cont.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
onMount((e,t,c) => {
88
if (Ct == 'Dublin City') {
99
let geo = wrapper.getBoundingClientRect()
10-
console.log("Con onMount", geo)
10+
//console.log("Con onMount", geo)
1111
}
1212
//if (Ct == 'Kerouac') debugger
1313
})

src/routes/Code.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
function bloop() {
5353
!dat && bleep()
5454
dat = St_loop(dat)
55+
delete dat.mind
5556
tocon(dat)
5657
refresh = dat.i
5758
console.log('bloop! '+refresh)
@@ -61,7 +62,8 @@
6162
6263
function busybusy () {
6364
sipd.o('1')
64-
//sipd.o('1.2.1.2.2')
65+
//sipd.o('1.2')
66+
sipd.o('1.2.1.2.2')
6567
// < ping only the -Cont etc? only -Con subscribe so far
6668
//sipd.o('1.2.1.2.2.1',refresh)
6769
}

0 commit comments

Comments
 (0)