;;;; An array literal with nothing outside it naming a type: elements that agree ;;;; are a typed array, numbers meeting at the wider and a literal taking the ;;;; others' type, and elements that do not are a dyn vector. (defstruct P [x i32 y i32]) (defn mixed [] i32 (let [x (i32 4) a [(f32 1.0) 2.5 3.25] b [(i64 1) 2 3] c [(u8 1) 300] d [x 2.5] e [1 18446744073709551615] f [10 "Hi"] g [nil 1] h [None (Some 3)] i [(P 1 2) {.x 3 .y 4}] j [[1 2] [3 4]] k [1 2.5] m [x (i64 5)] dd [:a "b" 3]] (println (length a)) (println (+ (at c 1) (i32 (at c 0)))) (println (at d 1)) (println (at e 1)) (println f) (println g) (println (length f)) (println (match (at h 1) None 0 (Some v) v)) (println (.y (at i 1))) (println (at (at j 1) 0)) (println (at k 0)) (println (+ (at m 0) (i64 9000000000))) (println dd)) 0) ;; (the T e) gives any expression its type. (defn the-forms [] i32 (let [a (the u8 200) b (the i64 5000000000) c (the f32 2.5) d (the [3 f32] [1 2 3.5]) e (the [f32] [1 2.5]) f (the (Option i32) None) g (the (Option i32) nil) h (the dyn 3) n (the i64 (+ (the i32 1) 2)) v (the (Vec i32) (vec-new))] (println (+ a (u8 55))) (println b) (println (* c (f32 2.0))) (println (+ (at d 0) (at d 2))) (println (length e)) (println (match f None 0 (Some x) x)) (println (match g None 7 (Some x) x)) (println h) (println n) (println (length v))) 0) (defn main [] i32 (mixed) (the-forms))