41 lines
954 B
Plaintext
41 lines
954 B
Plaintext
;; Return types read off the body: _ in the return slot here, no arrow in
|
|
;; main.fln. Each shape the rule has: one type, a call's type, a literal
|
|
;; that takes the other exit's type, a dyn beside a literal, nothing (()), a return
|
|
;; that never falls off the end, and a function that calls itself and gives
|
|
;; nothing.
|
|
|
|
(defn add [x i32 y i32] _ (+ x y))
|
|
|
|
(defn half [x f64] _ (/ x 2.0))
|
|
|
|
(defn quarter [x f64] _ (half (half x)))
|
|
|
|
(defn pick [c bool] _
|
|
(when c (return 1))
|
|
2.5)
|
|
|
|
(defn label [c bool d dyn] _
|
|
(when c (return d))
|
|
0)
|
|
|
|
(defn say [x i32] _ (println x))
|
|
|
|
(defn- floor0 [x i32] _
|
|
(if (< x 0) (return 0) x))
|
|
|
|
(defn countdown [n i32] _
|
|
(when (> n 0)
|
|
(println n)
|
|
(countdown (- n 1))))
|
|
|
|
(defn main [] i32
|
|
(println (add 1 2))
|
|
(println (quarter 10.0))
|
|
(println (+ (pick true) 0.5))
|
|
(println (pick false))
|
|
(println (label true "yes") (label false "yes"))
|
|
(say 4)
|
|
(println (floor0 -3) (floor0 5))
|
|
(countdown 2)
|
|
0)
|