2023-12-01 01:10:16 +00:00
|
|
|
(local fennel (require :fennel))
|
2023-12-03 16:49:11 +00:00
|
|
|
(import-macros {: def : q : ttype : static : unterra : untype} :terra)
|
|
|
|
|
2023-12-03 22:12:09 +00:00
|
|
|
(local Complex (ttype {real float imag float}))
|
2023-12-03 04:16:24 +00:00
|
|
|
(print (unterra
|
2023-12-03 22:12:09 +00:00
|
|
|
(def [: Complex] (return (Complex { real 5 imag 1 })))
|
|
|
|
))
|
|
|
|
(print (unterra
|
|
|
|
(def [c Complex r float] (tset c :real r))
|
|
|
|
))
|
|
|
|
(local thing (def [: Complex] (return (Complex { real 5 imag 1 }))))
|
|
|
|
(local get-real (def [val Complex] (return (. val :real))))
|
|
|
|
(local set-real (def [c [Complex] r float] (tset c :real r)))
|
2023-12-02 21:01:30 +00:00
|
|
|
|
2023-12-03 22:12:09 +00:00
|
|
|
(let [result (thing)]
|
|
|
|
(print result result.real result.imag (get-real result))
|
|
|
|
(set-real result 10)
|
|
|
|
(print (get-real result)))
|