core-logic

atroche 2016-10-18T22:03:04.000013Z

hi everyone, i’m using core.logic to help me implement http://mason.gmu.edu/~rhanson/equatalk.html

atroche 2016-10-18T22:03:43.000017Z

my problem is that i want the additional constraint that the numbers should form a roughly normal distribution

atroche 2016-10-18T22:04:20.000018Z

not sure if that gist link above is coming through right, but core.logic part starts at line 46

atroche 2016-10-18T22:04:50.000019Z

is there a way to do that with core.logic?

atroche 2016-10-18T22:49:48.000020Z

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?

2016-10-18T22:53:03.000021Z

you would have to express it as relations

2016-10-18T22:53:46.000022Z

each element in list X is one of the elements in list Y

2016-10-18T22:54:48.000023Z

the first element in list X is less than the second, etc

2016-10-18T22:57:12.000024Z

I am sure it can be done, but I am not sure I would do it

2016-10-18T22:58:00.000025Z

the logic stuff is sort of a combination of generators that generate possible matches and filters that reject things that don't match

2016-10-18T22:58:38.000026Z

so you'll end up generating all permutations of Y and rejecting the ones where your sorted relation doesn't hold

atroche 2016-10-18T22:59:27.000027Z

when you say you’re not sure you would do it, is it because of performance reasons?

2016-10-18T23:01:06.000028Z

it just seems like a mismatch between sorting and relational programming

2016-10-18T23:01:23.000029Z

maybe there is a paper some way with some cool prolog quicksort or something

2016-10-18T23:02:11.000030Z

me saying it seems like a mismatch, this guy saying it is beautiful

atroche 2016-10-18T23:11:24.000034Z

can’t say i understand how it works or even how to use it yet

atroche 2016-10-18T23:11:29.000035Z

do you, @hiredman ?

atroche 2016-10-18T23:12:34.000036Z

e.g. why does qsorto there have [l r r0] ?

2016-10-18T23:16:56.000037Z

I believe the [l r r0] line is for tabling

2016-10-18T23:17:46.000038Z

tabling is some kind of optimization sort of like memoizing

atroche 2016-10-18T23:17:57.000039Z

okay, cool

atroche 2016-10-18T23:18:13.000040Z

so if i’m looking for a constraint that says that the list is sorted

2016-10-18T23:18:22.000041Z

which is not say I understand qsorto

atroche 2016-10-18T23:18:28.000042Z

and i have the qsorto as written there…

atroche 2016-10-18T23:36:14.000043Z

i clearly have more reading to do 🙂