Closed Gerrrr closed 10 years ago
Nice! Want to add an example expansion to the issue? Then we can move this over to the documentation. Awesome work.
This is great! An example would be awesome.
Regards,
Dano On Mar 8, 2014 10:26 AM, "Sam Ritchie" notifications@github.com wrote:
Nice! Want to add an example expansion to the issue? Then we can move this over to the documentation. Awesome work.
Reply to this email directly or view it on GitHubhttps://github.com/nathanmarz/cascalog/pull/237#issuecomment-37103620 .
Thanks for the warm feedback.
Example with query taken from introduction tutorial:
user> (expand-query [?person ?a2] (age ?person ?age)
(< ?age 30) (* 2 ?age :> ?a2))
{:fields ["?person" "?a2"],
:predicates
({:op
[["alice" 28]
["bob" 33]
["chris" 40]
["david" 25]
["emily" 25]
["george" 31]
["gary" 28]
["kumar" 27]
["luanne" 36]],
:input nil,
:output ["?person" "?age"]}
{:op #<core$_LT_ clojure.core$_LT_@55c0c66a>,
:input ("?age" 30),
:output []}
{:op #<core$_STAR_ clojure.core$_STAR_@61415858>,
:input (2 "?age"),
:output ["?a2"]}),
:options
{:trap nil,
:spill-threshold nil,
:reverse nil,
:sort nil,
:distinct false,
:reducers nil}}
Awesome. I think if you use print vs pprint, these custom printers will take hold:
And you'll see an expanded version of the query without the explicit op, input, output. I like the way this looks, though.
So, now it looks like that:
user> (expand-query [?person ?a2] (age ?person ?age)
(< ?age 30) (* 2 ?age :> ?a2))
(<- [?person ?a2]
(#'cascalog.playground/age :> ?person ?age)
(#'clojure.core/< ?age 30)
(#'clojure.core/* 2 ?age :> ?a2)
)
very nice!
On Sat, Mar 8, 2014 at 3:15 PM, Aleksandr Sorokoumov < notifications@github.com> wrote:
So, now it looks like that:
user> (expand-query [?person ?a2](age ?person ?age) (< ?age 30) (* 2 ?age :> ?a2)) (<- [?person ?a2](#'cascalog.playground/age :> ?person ?age) (#'clojure.core/< ?age 30) (#'clojure.core/* 2 ?age :> ?a2) )
Reply to this email directly or view it on GitHubhttps://github.com/nathanmarz/cascalog/pull/237#issuecomment-37113059 .
Sweet! On Mar 8, 2014 4:15 PM, "Aleksandr Sorokoumov" notifications@github.com wrote:
So, now it looks like that:
user> (expand-query [?person ?a2](age ?person ?age) (< ?age 30) (* 2 ?age :> ?a2))(<- [?person ?a2](#'cascalog.playground/age :> ?person ?age) (#'clojure.core/< ?age 30) (#'clojure.core/* 2 ?age :> ?a2) )
Reply to this email directly or view it on GitHubhttps://github.com/nathanmarz/cascalog/pull/237#issuecomment-37113059 .
It gets better when you start to include predicate macros and other sugary delicacies.
LGTM
Implementation for https://github.com/nathanmarz/cascalog/issues/27