24 lines
958 B
Plaintext
24 lines
958 B
Plaintext
;;;; A program's function named as a prelude function takes the name over for
|
|
;;;; the calls in its own file, and the prelude's own calls keep the prelude's:
|
|
;;;; ceil-f32 is written over the prelude's floor-f32, and still answers 3.
|
|
;;;; A prelude macro is taken over the same way: clamp and update below are
|
|
;;;; the program's functions, and format-f64, which the prelude writes with
|
|
;;;; its own clamp, still clamps its precision to 9.
|
|
(defn abs-f32 [v f32] f32 (if (< v 0.0) (- v) (+ v (f32 100.0))))
|
|
(defn floor-f32 [x f32] f32 (f32 999.0))
|
|
(defn abs [x i32] i32 (* x 10))
|
|
(defn clamp [x i32 lo i32 hi i32] i32 (+ x lo hi))
|
|
(defn update [x i32] i32 (* x 7))
|
|
(defn main [] i32
|
|
(println (abs-f32 (f32 -2.5)))
|
|
(println (abs-f32 (f32 2.5)))
|
|
(println (floor-f32 (f32 2.3)))
|
|
(println (ceil-f32 (f32 2.3)))
|
|
(println (abs -3))
|
|
(println (clamp 1 2 3))
|
|
(println (update 6))
|
|
(let [s (format-f64 0.5 40)]
|
|
(println (length s))
|
|
(free s))
|
|
0)
|