Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by
I think it may be useful to be able to tie multiple noms in one binder, with or without significant order.

A couple use cases I've thought of so far:

Lambdas in a non-currying language. Here order matters.

(== (list 'fn (ties [x y] (list '+ x y)))
    (list 'fn (ties [z w] (list '+ z w)))


My original use case, free/quantified variables in logical formulas. Order doesn't matter (note the second body has its noms swapped).

(== (list '∀ (ties #{x y} (list '= (list '+ x y) (list '+ y x))))
    (list '∀ (ties #{z w} (list '= (list '+ w z) (list '+ z w)))))



I have a draft implementation here: https://github.com/tomjack/core.logic/compare/ties

Possible issues with this implementation:
- Is it OK to reextend IWalkTerm to IPersistentSet?
- Should Tie and Ties present a uniform interface? (e.g. (tie? (ties #{x} x)))

4 Answers

0 votes
by

Comment made by: dnolen

I really don't think the set bit is necessary, the vector syntax is fine. Also avoid needing to bring IWalkTerm back for sets. And yes, tie? should work in either case.

0 votes
by

Comment made by: tomoj

Hmm.. should:

`
(== (list 'fn (ties [x y] (list '- x y)))

(list 'fn (ties [z w] (list '- w z)))

`

I'd think not.

Do you mean that order should always matter (take out the permutations stuff), or that it should never matter (don't use ties for cases like the above)?

0 votes
by

Comment made by: dnolen

Ah hm, good point. Will think on it some more.

0 votes
by
Reference: https://clojure.atlassian.net/browse/LOGIC-138 (reported by tomoj)
...