Open
Description
Describe the bug
foldl-atom works when provided with a function but if the function is substituted by it's body it breaks
To Reproduce
(= (remove $list $elem)
(if-decons-expr $list $head $tail
(unify $elem $head ($head $tail) (let ($res $ntail) (remove $tail $elem) ($res (cons-atom $head $ntail))))
(() $list)
))
;;Helper function for overlap
(= (overlap_ff ($left $intersection $right) $elem)
(let ($res $nright) (remove $right $elem)
(if (== $res ())
((cons-atom $elem $left) $intersection $right)
($left (cons-atom $res $intersection) $nright))))
;;Calculate the overlap of 2 sets
;;Retruns (($list1 - $list2) ($list1 intersection $list2) ($list2 - $list1))
;;Variables are treated as matchichg any set
(= (overlap $list1 $list2)
(foldl-atom $list1 (() () $list2) $accum $elem
(overlap_ff $accum $elem)))
!(overlap (a b c) (b c d))
;[((a) (c b) (d))] this works
(= (overlap2 $list1 $list2)
(foldl-atom $list1 (() () $list2) $accum $elem
(let ($left $intersection $right) $accum
(let ($res $nright) (remove $right $elem)
(if (== $res ())
((cons-atom $elem $left) $intersection $right)
($left (cons-atom $res $intersection) $nright))))))
!(overlap2 (a b c) (b c d))
;[] this doesn't
Expected behavior
both functions should output the same