mastodon.sdf.org is part of the decentralized social network powered by Mastodon.
"I appreciate SDF but it's a general-purpose server and the name doesn't make it obvious that it's about art." - Eugen Rochko

Administered by:

Server stats:

2.6K
active users

Learn more

@jeremy_list
lineage tracing eg discussion

hey I wanted to relate and so I was looking at your example from before:
gopher://thunix.net/0/~jeremyl
or for the ungopherful
portal.mozz.us/gopher/thunix.n

Is this lisp a good match for what you did?

(defun f-rassoc (child ancestor family)
(let ((person (rassoc ancestor family :test 'member)))
(when person
(if (equal (car person) child) T
(f-rassoc child (car person) family)))))

thunix.netportal.mozz.us

@jeremy_list
Edit: In hindsight, the simple use of rassoc only permits one or zero children in general. Hmm.

Lisp one:
CLIM-USER> *f*
((A B C) (B D E) (C F G) (D I J) (J K L))
CLIM-USER> (f-rassoc 'a 'k *f*)
T
CLIM-USER> (f-rassoc 'a 'm *f*)
NIL
CLIM-USER> (f-rassoc 'a 'a *f*)
NIL

@jeremy_list I would say the difference is that I am able to use the (child parent1 parent2) type [] because I can use rassoc :test 'member on an association list, whereas your haskell one is using a hash-table structure.

They're both concise and downwards.

screwlisp

@jeremy_list I also wrote this one (rather than acl2) before looking at yours properly as a point of comparison.
(defun ancestorp
(a b f)
(loop
:with candidates := `(,a)
:for name := (pop candidates)
:for subtree := (assoc name f)
:if (member b (cdr subtree)) :return subtree
:else :Do
(setf candidates (append (cdr subtree) candidates))
:while candidates))

@jeremy_list cc @abuseofnotation @me if you care to comment as well. I picked jeremy_list's to look at because it was concise, I did think about the three different strategies.

Jencel haskell:
mathstodon.xyz/@abuseofnotatio

My acl2 one again, just while we're here:
mastodon.sdf.org/@screwtape/11

jlamothe's haskell
social.jlamothe.net/display/c3

Jencel Panic (@abuseofnotation@mathstodon.xyz)Mathstodon

@screwtape @jeremy_list @me I think what I do is the most plain approach, as I don't use any helpers, except "find" --- just lists and recursion.

@abuseofnotation
Yes, having spent a painful afternoon revising my approach, I guess so. I'll do an acl2 mutual-recursion like yours later.

The series version I experimented with today: codeberg.org/tfw/lineage-traci

lineage tracing,
@jeremy_list @me

lineage-tracing/lineage-tracing.lisp at masterForgejo: Beyond coding. We Forge.