diff --git a/TODO.md b/TODO.md index 4098891..7147258 100644 --- a/TODO.md +++ b/TODO.md @@ -14,5 +14,37 @@ - modifiers in fld/grp/map -- -@ conditional drop +- -@ conditional drop? (in selectors) + +fix arguments in qryd, jsnqryf etc. + + + + +?map +args: vec, kv +#(expr .. expr) do this sequence of expressions on each item in object. + +** +args: vec, kv +[expr .. expr] filter object by these expressions + +$$ +{sel .. sel} select keys/exprs from ht to new ht + +*$ +args: vec +#{sel .. sel} select from vec of hts to vec of hts + +$* +args: vec +#[sel .. sel] select from vec of hts to vec + + +args: vec, kv +?fld + +args: vec, kv +?grp + diff --git a/docs/lqn.md b/docs/lqn.md index 30c51dc..1cea1e0 100644 --- a/docs/lqn.md +++ b/docs/lqn.md @@ -9,7 +9,7 @@ ; ?? names a macro: ; Lambda-list: (A EXPR &OPTIONAL RES) ; Documentation: - ; evaluate expr only iff a is not nil. returns the result of expr or res; or nil. + ; evaluate expr only if a is not nil. returns the result of expr or res; or nil. ; Source file: /data/x/lqn/src/qry-utils.lisp ``` @@ -1064,6 +1064,19 @@ ; Source file: /data/x/lqn/src/qry.lisp ``` +#### LQN:QRYDB + +``` + ; LQN:QRYDB + ; [symbol] + ; + ; QRYDB names a macro: + ; Lambda-list: (DAT &REST REST) + ; Documentation: + ; query data. rest is wrapped in the pipe operator. + ; Source file: /data/x/lqn/src/qry.lisp +``` + #### LQN:QRYL ``` diff --git a/src/packages.lisp b/src/packages.lisp index 2c2600f..21d3678 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -2,7 +2,7 @@ (:use #:common-lisp) (:nicknames #:cl-lqn) (:export #:d? #:v? - #:qry #:qryd #:jsnqryf #:qryl #:proc-qry + #:qry #:qrydb #:qryd #:jsnqryf #:qryl #:proc-qry #:jsnloads #:jsnloadf #:jsnout #:ldnout #:ldnload #:fmt #:out #:jsnstr #:?q #:@* #:@@ #:?? #:read? #:some? #:none? #:all? #:empty? #:size? #:is? #:path? #:subdir #:subfiles #:ls #:dir? #:file? #:cwd #:now #:cmd diff --git a/src/qry-utils.lisp b/src/qry-utils.lisp index b6adf91..0a900f8 100644 --- a/src/qry-utils.lisp +++ b/src/qry-utils.lisp @@ -105,7 +105,7 @@ match. If b is an expression, a is compared to the evaluated value of b." (otherwise d))) (defmacro ?? (a expr &optional res) (declare (symbol a)) ; TODO: dont require sym? - "evaluate expr only iff a is not nil. returns the result of expr or res; or nil." + "evaluate expr only if a is not nil. returns the result of expr or res; or nil." `(and ,a ,expr ,@(if res `(,res)))) (defun @@ (a path &optional d) (declare #.*opt*) diff --git a/src/qry.lisp b/src/qry.lisp index ba6a5a7..714b942 100755 --- a/src/qry.lisp +++ b/src/qry.lisp @@ -105,8 +105,9 @@ (∈ (:key ,kk) ,(compile/$add rec (dat/new conf dat) m kres kk expr))))) ($nil ,kres)))) +; rename this to (?@ ) or something? (defun compile/$* (rec conf d) ; #[...] ; sel - (awg (i ires itr dat par) ; TODO: adapt to support hts? + (awg (i ires itr dat par) `(loop with ,ires of-type vector = (mav) with ,par of-type vector = (vec! ,(gk conf :dat)) for ,itr across ,par for ,i from 0 @@ -142,7 +143,7 @@ (loop for (m expr) in (strip-all cd) if (member m mm :test #'eq) collect expr)) (defun compile/** (rec conf d) ; [...] ; sel, filter - (awg (i ires itr par) + (awg (i ires itr par) ; TODO: adapt to support hts? `(loop with ,ires of-type vector = (mav) with ,par of-type vector = (vec! ,(gk conf :dat)) for ,itr across ,par for ,i from 0 @@ -246,7 +247,7 @@ `(qryd ,dat (|| ,@rest))) (abbrev ?q qry) (defmacro qrydb (dat &rest rest) "query data. rest is wrapped in the pipe operator." - `(qryd ,dat (|| ,@rest) :db t)) + `(qryd ,dat (|| ,@rest) :db t)) ; TODO: rename to vqry? (defun qryl (dat q &key db) "compile lqn query and run on dat" (eval `(qryd ,dat ,q :db ,db))) (defmacro jsnqryf (fn q &key db) "run lqn query on json file, fn"