@jeremy_list
lineage tracing eg discussion
hey I wanted to relate #lisp and #haskell so I was looking at your #gopher example from before:
gopher://thunix.net/0/~jeremylist/lineage.hs
or for the ungopherful
https://portal.mozz.us/gopher/thunix.net/0/~jeremylist/lineage.hs
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)))))
@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.
@jeremy_list I also wrote this #commonLisp 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:
https://mathstodon.xyz/@abuseofnotation/114177319663862391
My acl2 one again, just while we're here:
https://mastodon.sdf.org/@screwtape/114177238597816382
jlamothe's haskell
https://social.jlamothe.net/display/c35d279b-1867-d8aa-0426-c89455576760
@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: https://codeberg.org/tfw/lineage-tracing/src/branch/master/lineage-tracing.lisp
lineage tracing, #programming #commonLisp #series
@jeremy_list @me