Add Stream support for field accessors

The type checker now correctly handles unwrapping `Stream(T)` types for
lambda arguments.
A new `build_map_stream` function has been added to `rtl/streams.rs` to
facilitate field access on streams.
The `create-random-ohlc` function now returns a `Stream` instead of a
`Series`.
Examples have been updated to reflect these changes and demonstrate
stream usage.
This commit is contained in:
Michael Schimmel
2026-03-07 20:47:05 +01:00
parent 2023df2f62
commit f88992da61
6 changed files with 105 additions and 28 deletions
+6 -8
View File
@@ -1,12 +1,10 @@
#use rtl
(do
(def sma20 (SMA 20))
(def n 100)
(while (> n 0)
(do
(print "val=" n " sma20=" (sma20 n))
(assign n (- n 1))
))
(def src (create-random-ohlc 42 200))
(macro printx [s] `(fn [x] (print ~s x)))
(pipe [(.close src)] (printx "close="))
(pipe [(pipe [(.close src)] (SMA 20))] (printx "sma="))
)
+10
View File
@@ -0,0 +1,10 @@
(do
(def stream (create-random-ohlc 42 200))
(macro prt [m] `(pipe (~m stream) (fn [s] (print ~m "=" s))))
(prt .open)
(prt .high)
(prt .low)
(prt .close)
)