d2cba2d55d
The `series` constructor now only accepts the `lookback` limit. The element type is inferred by the type checker and implicitly added as a schema argument during compilation. This simplifies the API and centralizes type inference. This change also includes: - Updates to example scripts (`HMA.myc`, `sma.myc`, `soa_series.myc`) to reflect the new `series` signature. - Modifications to the `TypeChecker` to handle the inferred schema injection. - An addition of a regression test for type inference through nested closures with `series`. - Removal of `#[allow(dead_code)]` from several `TypeChecker` methods as they are now used. - Update to `rtl/prelude.myc` macro `cache`. - Update to `rtl/series/mod.rs` to reflect new signature. - Update to `ast/types.rs` to allow `series` to be indexed with an integer to retrieve its element type.
15 lines
383 B
Plaintext
15 lines
383 B
Plaintext
;; Benchmark: 1.1us
|
|
;; Benchmark-Repeat: 1877
|
|
(do
|
|
(def my_ticks (series 100))
|
|
|
|
(push my_ticks {:price 10.5 :volume 100 :msg "A"})
|
|
(push my_ticks {:price 11.2 :volume 200 :msg "B"})
|
|
(push my_ticks {:price 15.5 :volume 300 :msg "C"})
|
|
|
|
(def prices (.price my_ticks))
|
|
|
|
;; prices 0 = 15.5 (newest), prices 1 = 11.2
|
|
(assert-eq 26.7 (+ (prices 0) (prices 1)))
|
|
)
|