4dfdc75545
- Add `rtl/system.myc` as the system library, containing core utilities like `while` and `cache`. - Remove the duplicate `prelude.myc` from `src/ast/rtl/`. - Modify `Environment::collect_dependencies` to implicitly add `#use system` when necessary. - Update `Environment::with_cwd` to also add the `rtl` subdirectory to search paths. - Add `target/` to `.geminiignore` to exclude build artifacts. - Adjust example `sma.myc` to use the new `cache` macro and reduce sample data size. - Update `rtl/sma.myc` to correctly initialize the `history` series with its `length`. - Add `preload_dependencies` calls to `dump_ast` and `run_script` for proper module loading.
21 lines
560 B
Plaintext
21 lines
560 B
Plaintext
#use rtl
|
|
|
|
(do
|
|
(def src (create-random-ohlc 42 200))
|
|
|
|
(macro printx [s] `(fn [x] (print ~s x)))
|
|
|
|
(pipe src print)
|
|
(pipe [(pipe [(.close src)] (SMA 20))] (printx "sma20="))
|
|
(pipe [(pipe [(.close src)] (SMA 5))] (printx "sma5="))
|
|
(pipe [(pipe [(.close src)] (SMA 100))] (printx "sma100="))
|
|
|
|
(macro cache [lookback type src] `(do (def data (series ~lookback ~type)) (pipe [~src] (fn [s] (do (push data s)))) data))
|
|
|
|
; (def bars (series 20 :float))
|
|
; (pipe [src] (fn [s] (do (push bars (.close s)))))
|
|
|
|
(cache 20 :float src)
|
|
|
|
)
|