Skip to content

Commit

Permalink
cursor docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
leonoel committed Jan 26, 2024
1 parent 6ed375f commit c277207
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/hyperfiddle/electric_de.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@
(defmacro client [& body] `(::lang/site :client ~@body))
(defmacro server [& body] `(::lang/site :server ~@body))

(defmacro cursor [bindings & body]
(defmacro cursor "
Syntax :
```clojure
(cursor [sym1 table1
sym2 table2
,,, ,,,
symN tableN]
& body)
```
For each tuple in the cartesian product of `table1 table2 ,,, tableN`, calls body in an implicit `do` with symbols
`sym1 sym2 ,,, symN` bound to the singleton tables for this tuple. Returns the concatenation of all body results.
" [bindings & body]
(case bindings
[] `(do ~@body)
(let [[args exprs] (apply map vector (partition-all 2 bindings))]
Expand Down

0 comments on commit c277207

Please sign in to comment.