Carp/examples/vec2.carp
2017-09-08 12:24:57 +02:00

31 lines
596 B
Plaintext

(use IO)
(use String)
(use Int)
(deftype Vec2
[x Int
y Int])
(defmodule Vec2
(defn str [v]
(append
(append @"x: " (Int.str (Vec2.x v)))
(append @", y: " (Int.str (Vec2.y v)))))
(defn basic [] (Vec2.init 10 20)))
(defmodule Advanced
(deftype Mat4 [x Int]))
(defn main []
(let [v (ref (Vec2.basic))]
(do
(println (ref (Vec2.str v)))
(println (ref (str (Advanced.Mat4.x
(ref (Advanced.Mat4.set-x
(Advanced.Mat4.init 100)
200)))))))))
(build)
(run)
(quit)