Re: Solving this with logic programing

2011-11-08 Thread Ambrose Bonnaire-Sergeant
Hi Michael, Interesting implementation, personally I'm not well versed in programming with sets. Looks like a very nice style, will use this to check it out. Thanks, Ambrose On Mon, Nov 7, 2011 at 2:26 AM, Michael Jaaka wrote: > Well, despite of fact that core.logic is fine tool and is worth of

Re: Solving this with logic programing

2011-11-06 Thread Michael Jaaka
Well, despite of fact that core.logic is fine tool and is worth of study, I have implemented own solution to my problem. Here is a full implementation: http://pastebin.com/Z5BETZd3 And the idea is to index each value in record perserving the record and meaning of values. Then search by these va

Re: Solving this with logic programing

2011-11-05 Thread David Nolen
There's nothing like a Learn You A core.logic, but Ambrose and Ryan Senior's tutorials are pretty great. https://github.com/frenchy64/Logic-Starter/wiki http://objectcommando.com/ David On Sat, Nov 5, 2011 at 3:34 PM, Michael Jaaka wrote: > > Btw. Is there any fine tutorial for core.logic? By f

Re: Solving this with logic programing

2011-11-05 Thread Michael Jaaka
Btw. Is there any fine tutorial for core.logic? By fine I mean something like learn haskell for great good. On 5 Lis, 20:26, Michael Jaaka wrote: > Now is ok, easy to grasp. How the lein dep declaration and clj import > looks? > Thank you both. > > On 5 Lis, 20:11, David Nolen wrote: > > > > >

Re: Solving this with logic programing

2011-11-05 Thread Michael Jaaka
Now is ok, easy to grasp. How the lein dep declaration and clj import looks? Thank you both. On 5 Lis, 20:11, David Nolen wrote: > I would probably write the code like this: > > (defrel permission role op state) > > (defn add-permision [roles ops states] >   (doseq [r roles o ops s states] >    

Re: Solving this with logic programing

2011-11-05 Thread David Nolen
I would probably write the code like this: (defrel permission role op state) (defn add-permision [roles ops states] (doseq [r roles o ops s states] (fact permission r o s))) (add-permision #{:admin :operator} #{:reject :accept} #{:applied}) (defn permissiono [role op state] (run* [q]

Re: Solving this with logic programing

2011-11-05 Thread Michael Jaaka
Thanks, it gave me insight into that framework. Unfortunately it doesn't look friendly in usage. Looks like there is a place for a clojure lib or wrapper around core.logic. It would be nice if it could answer to questions also in terms of truth. On 5 Lis, 18:24, Ambrose Bonnaire-Sergeant wrote:

Re: Solving this with logic programing

2011-11-05 Thread David Nolen
For wildcards you can use symbol-macrolet from tools.macro (macro/symbol-macrolet [_ (lvar)] (all (== [_ _ [_ _ 'milk _ _] _ _] hs) )) On Sat, Nov 5, 2011 at 1:24 PM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > I gave the wildcard requirement a bit of though

Re: Solving this with logic programing

2011-11-05 Thread Ambrose Bonnaire-Sergeant
I gave the wildcard requirement a bit of thought, no inspiration at the moment. Maybe someone else can suggest a strategy. Ambrose On Sun, Nov 6, 2011 at 1:14 AM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > Hey Michael, > > Here's a solution using core.logic. > > ;; We can

Re: Solving this with logic programing

2011-11-05 Thread Ambrose Bonnaire-Sergeant
Hey Michael, Here's a solution using core.logic. ;; We can define a "permission" relation with "defrel". (defrel permission roles ops state) ;; and a helper function to add each combination of permissions (defn add-permision [roles ops states] (for [r roles o ops s states]

Solving this with logic programing

2011-11-05 Thread Michael Jaaka
Hi, I would like to use logic programing to describe permissions. The definition is We have set of triples which looks like: Set of roles; set of operations; set of states Triples are defined in scope of some entity with states, wildcard is defined with _ All I need is to answer on some operati