Fork me on GitHub
#core-logic
<
2016-10-18
>
atroche22:10:04

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

atroche22:10:43

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

atroche22:10:20

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

atroche22:10:50

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

atroche22:10:48

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?

hiredman22:10:03

you would have to express it as relations

hiredman22:10:46

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

hiredman22:10:48

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

hiredman22:10:12

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

hiredman22:10:00

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

hiredman22:10:38

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

atroche22:10:27

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

hiredman23:10:06

it just seems like a mismatch between sorting and relational programming

hiredman23:10:23

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

hiredman23:10:11

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

atroche23:10:24

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

atroche23:10:34

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

hiredman23:10:56

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

hiredman23:10:46

tabling is some kind of optimization sort of like memoizing

atroche23:10:57

okay, cool

atroche23:10:13

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

hiredman23:10:22

which is not say I understand qsorto

atroche23:10:28

and i have the qsorto as written there…

atroche23:10:14

i clearly have more reading to do 🙂