Skip to content

Commit a3308bc

Browse files
committed
aog wip
1 parent 1091e50 commit a3308bc

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/data_visualization/aog_in_clojure_part1.clj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,8 @@ iris
24742474

24752475
;; ### 🧪 Example 1: Simple Scatter Plot (Delegated Domain)
24762476

2477+
;; **Algebraic style using `=*`:**
2478+
24772479
(=* (data penguins)
24782480
(mapping :bill-length-mm :bill-depth-mm)
24792481
(scatter))
@@ -2491,6 +2493,21 @@ iris
24912493
(and (map? (meta rendered))
24922494
(= (:kindly/kind (meta rendered)) :kind/html))))])
24932495

2496+
;; **Threading macro style (equivalent):**
2497+
2498+
(-> penguins
2499+
(mapping :bill-length-mm :bill-depth-mm)
2500+
(scatter))
2501+
2502+
(kind/test-last [#(and (map? %)
2503+
(contains? % :=layers)
2504+
(= (:=x (first (:=layers %))) :bill-length-mm)
2505+
(= (:=y (first (:=layers %))) :bill-depth-mm)
2506+
(= (:=plottype (first (:=layers %))) :scatter))])
2507+
2508+
;; Both forms produce identical results. The threading style is often more
2509+
;; natural in Clojure, while the `=*` style makes the composition operator explicit.
2510+
24942511
;; **What happens here**:
24952512

24962513
;; 1. We create a plot spec with data, mapping, and plottype

0 commit comments

Comments
 (0)