[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
foldts for building graphs
From: |
Catonano |
Subject: |
foldts for building graphs |
Date: |
Thu, 19 Mar 2020 13:22:59 +0100 |
I'd like to build a tree that has the exact same shape of the tree made of
tree-il records
BUT I want my tree to be made of cons cells and vectors. No more
So lists, alists and vectors.
But no more.
Because those can be pretty printed.
tree-il trees can be printed but they're not so pretty
I'm using "tree-il-fold"
When going _down_ along a branch, I know what to do
I can add the visited node as a child of the previously visited node
The problem is when stepping _up_
Because in the accumulator I think I should track the fact
that the visiting process is currently on a node that is a step up
in regard to the previous visiting step
Shouldn't I ?
I don't know how to do this
In Clojure I would have represented my accumulator as a map
and I would have marked the "current" node with a key value couple,
with something along the lines of
[curly brackets are like parenses but for dictionary like structures in
Clojure]
{... {... {... #:current? #t ...} ...} ...}
Clojure maps are immutable so a new map would be created at every recursion
step
But behind the curtains, the structure doesn't get replicated as a whole,
but rather versioned
and the new versions share some memory with the previous ones
This is what happens with vanilla list processing in scheme
so writing purely functional code is convenient (easy, compact)
and not so wasteful
In Guile such a facility doesn't exist, as far as I understand
Should that not work, in Clojure there are also the so called zippers
Neither zippers are available in Guile, as far as I understand
So how do I do this ?
How do I replicate a tree-il based tree in vanilla cons cells ?
maybe I should take a look at lenses ?
https://gitlab.com/a-sassmannshausen/guile-lens/-/blob/master/doc/lens.texi
I still didn't study them
Thanks in advance
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- foldts for building graphs,
Catonano <=