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
<[email protected]>wrote:

> 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 values. The mini DSL contains "from
> insert select where" keywords.
>
> The resulting usage code is:
>
> (defn permission[ roles ops states ]
> (letfn [ (or-nil [ a ] (or a #{ nil })) ]
> (from :permission
> (doseq[ r (or-nil roles) o (or-nil ops) s (or-nil states) ]
> (insert { :role r :op o :state s })))))
>
> (permission #{:admin :operator } #{:reject :accept} #{:applied} )
> (permission #{:auditor :operator } #{:list} any )
> (permission #{:operator } #{:enter} #{:dirty} )
>
> (defn can-access[ role op state ]
> (not (empty? (from :permission
> (where { :role role :op op :state state })))))
>
> (defn get-operations[ role state ]
> (map :op (from :permission
> (select [ :op ]
> (where { :role role :state state })))))
>
> ; Some tests
>
> (get-operations  :operator :applied)
> (can-access :auditor :list :applied)
> (can-access :admin :enter :dirty)
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to