12 lines
434 B
Plaintext
12 lines
434 B
Plaintext
;;;; Constant integer arithmetic stands where a bounded type variable is
|
|
;;;; wanted, as the single literal it folds to would.
|
|
(defn f [x $t] t {:where (numeric? $t)} (+ x (* 2 (+ 1 2))))
|
|
(defn g [x $t] t {:where (integer? $t)} (- x (% 7 4)))
|
|
|
|
(defn main [] i32
|
|
(println (f 4)) ; 10
|
|
(println (f (u8 250))) ; 0, u8 arithmetic wrapping
|
|
(println (f 1.5)) ; 7.5
|
|
(println (g (i64 10))) ; 7
|
|
0)
|