concept query in category clojure

appears as: query, The queries, query, queries
The Joy of Clojure, Second Edition

This is an excerpt from Manning's book The Joy of Clojure, Second Edition.

The Clojure clojure.java.javadoc namespace has a javadoc function to query and view official API documentation: (javadoc frame). This should return a string corresponding to a URL and open a browser window for the right page of documentation. Prior to Clojure 1.2, this function was in clojure.contrib.repl-utils.

Listing 16.8. Querying planetary bodies
(logic/run* [q] #1   (logic/fresh [orbital body] #2     (orbits orbital body)     (logic/== q orbital))) #3 ;;=> (:earth :saturn :jupiter :mars ;;    :mercury :neptune :uranus :venus) #1 – 1 Define the query lvar #2 – 2 Define local lvars #3 – 3 Unify the query !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[]"} !@%STYLE%@!

Now the query reads more nicely:

Now that you have the data processors in place and operating as you expect, you can start to think about cleaning up the DSL so your users don’t need to explicitly quote the clause elements but can instead write queries in a more natural way. This is where macros come into play: now that you’ve built your DSL infrastructure on data and processors, you can use macros to provide some syntactic sugar. First, it’s not a terribly compelling DSL if it requires you to use long clauses with names of the form process-*-clause. Instead, it would be fun to define a mapping from more relevant names like SELECT and FROM. You can describe this name mapping directly to the functions that provide the data processing: