hi everyone, i’m using core.logic to help me implement http://mason.gmu.edu/~rhanson/equatalk.html
my problem is that i want the additional constraint that the numbers should form a roughly normal distribution
not sure if that gist link above is coming through right, but core.logic part starts at line 46
is there a way to do that with core.logic?
actually, let me ask another simpler question first: what’s a good way to sort a list of numbers in core.logic, or to find the median of them?
you would have to express it as relations
each element in list X is one of the elements in list Y
the first element in list X is less than the second, etc
I am sure it can be done, but I am not sure I would do it
the logic stuff is sort of a combination of generators that generate possible matches and filters that reject things that don't match
so you'll end up generating all permutations of Y and rejecting the ones where your sorted relation doesn't hold
when you say you’re not sure you would do it, is it because of performance reasons?
it just seems like a mismatch between sorting and relational programming
maybe there is a paper some way with some cool prolog quicksort or something
me saying it seems like a mismatch, this guy saying it is beautiful
https://www.cp.eng.chula.ac.th/~piak/teaching/dsys/2004/quick-prolog.htm
can’t say i understand how it works or even how to use it yet
do you, @hiredman ?
e.g. why does qsorto there have [l r r0] ?
I believe the [l r r0] line is for tabling
tabling is some kind of optimization sort of like memoizing
okay, cool
so if i’m looking for a constraint that says that the list is sorted
which is not say I understand qsorto
and i have the qsorto as written there…
i clearly have more reading to do 🙂