<Mozillion>
hmm.. I'm printing a AST using Format/fprintf.. which works nice with fprintf f "%a%a%a" node a foo b bar c and such
<Mozillion>
but now I have to number the nodes.. that is depth-first wise... so I've tried something like fprintf f "%a%a%a" node (n, a) foo (n + 1, b) bar (n + 1, c)
<Mozillion>
but that is obviously incorrect buecause function foo f (n, elem) could expand to for example five nodes so the 'bar' branches will have been numbered wrong
<Mozillion>
since the printing functions can't return anything.. someone any idea how to do this recursively?
<Mozillion>
s/bar (n + 1, c)/bar (n + 2, c)/
<vodka-goo>
I'm not sure whether I understand completely
<vodka-goo>
but I'd use a ref
<vodka-goo>
not purely functional, but it doesn't hurt if you use a local one
<vodka-goo>
see what I mean ?
<Mozillion>
so start with n being a ref to 0, and then pass n on.. each function incrementing it
<vodka-goo>
yeah
<Mozillion>
great, yes
<vodka-goo>
if you want your code to be thread-safe you should take care of not sharing the reference (shouldn't be too hard)
<Mozillion>
nah, it only exist within the tree walking functions
<Mozillion>
besides, there are no threads :P
<Mozillion>
pfoo.. it's quite a lot of usage of 'n' to change... let's postpone that till tomorrow
<Mozillion>
gnight.. and thanks
Mozillion has quit ["Client exiting"]
Bigbang is now known as Bigb[a]ng
smimou has quit ["bli"]
mkhl has quit [Connection reset by peer]
vodka-goo has quit ["Connection reset by by pear"]
Smerdyakov has joined #ocaml
_fab has quit [Read error: 110 (Connection timed out)]
pango_ has joined #ocaml
Smerdyakov has quit ["Leaving"]
pango has quit [Read error: 104 (Connection reset by peer)]
shirogane has joined #ocaml
quamaretto has joined #ocaml
monochrom has quit ["good morning, sweet dream"]
quamaretto has quit ["Leaving"]
cmeme has quit [Dead socket]
cmeme has joined #ocaml
shirogane has quit [Remote closed the connection]
ramkrsna has quit [Read error: 110 (Connection timed out)]
bluestorm has joined #ocaml
bluestorm has quit [Remote closed the connection]
bluestorm has joined #ocaml
_fab has joined #ocaml
goron has joined #ocaml
goron has left #ocaml []
mwc has joined #ocaml
smimou has joined #ocaml
vodka-goo has joined #ocaml
vodka-goo has quit [Client Quit]
ski has joined #ocaml
WFrag has joined #ocaml
m3ga has joined #ocaml
mwc_ has joined #ocaml
mwc__ has joined #ocaml
mwc has quit [Read error: 110 (Connection timed out)]
mwc has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
mwc__ has quit [Read error: 110 (Connection timed out)]
mwc_ has quit [Read error: 110 (Connection timed out)]
mwc has quit [Read error: 110 (Connection timed out)]
mwc has joined #ocaml
descender has joined #ocaml
ski has quit ["NMI"]
mwc has quit ["Leaving"]
_fab has quit [Remote closed the connection]
_fab has joined #ocaml
WFrag has left #ocaml []
Revision17 has joined #ocaml
_JusSx_ has joined #ocaml
Smerdyakov has joined #ocaml
Smerdyakov has quit ["Leaving"]
descender has quit ["XML is like violence, if it doesn't solve the problem, just use more."]
monochrom has joined #ocaml
KrispyKringle is now known as McGuiver
McGuiver is now known as KrispyKringle
shirogane has joined #ocaml
Smerdyakov has joined #ocaml
Raziel has quit [Read error: 104 (Connection reset by peer)]