Skip to content

Commit

Permalink
todos
Browse files Browse the repository at this point in the history
  • Loading branch information
inconvergent committed Mar 11, 2024
1 parent b333b29 commit 3cbdf00
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
34 changes: 33 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion docs/lqn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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

```
Expand Down
2 changes: 1 addition & 1 deletion src/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/qry-utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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*)
Expand Down
7 changes: 4 additions & 3 deletions src/qry.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 3cbdf00

Please sign in to comment.