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:
+6
-8
@@ -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="))
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
Reference in New Issue
Block a user