Add RecordSeries::get_record and support for (my_ticks 0)

This commit introduces the `get_record` method to `RecordSeries`,
allowing for the dynamic reconstruction of a full record from its
constituent fields at a given index. This enables idiomatic access to
series data using indexing like `(my_ticks 0)`.

The `push-series` function has also been updated to correctly handle the
structure of records when pushing data into a `RecordSeries`.
This commit is contained in:
Michael Schimmel
2026-03-01 18:44:46 +01:00
parent b612df6e10
commit 46b546446f
3 changed files with 58 additions and 17 deletions
+6 -6
View File
@@ -1,15 +1,15 @@
;; Output: 26.7
;; Benchmark: 998ns
;; Benchmark: 998ns
;; Benchmark-Repeat: 2047
(do
(def template {:price 10.0 :volume 100})
(def template {:price 10.0 :volume 100 :msg "hi"})
(def my_ticks (create-series template))
(push-series my_ticks {:price 10.5 :volume 100})
(push-series my_ticks {:price 11.2 :volume 200})
(push-series my_ticks {:price 15.5 :volume 300})
(push-series my_ticks {:price 10.5 :volume 100 :msg "A"})
(push-series my_ticks {:price 11.2 :volume 200 :msg "B"})
(push-series my_ticks {:price 15.5 :volume 300 :msg "C"})
(def prices (.price my_ticks))
(+ (prices 0) (prices 1))
)
)