(module forma_4_intmath_lib

  (fn square
    (doc "Multiply an Int by itself.")
    (type (fn-type (params (own (con Int))) (ret (own (con Int)))))
    (params x)
    (body (app * x x)))

  (fn cube
    (doc "Raise an Int to the third power.")
    (type (fn-type (params (own (con Int))) (ret (own (con Int)))))
    (params x)
    (body (app * x (app square x))))

  (fn abs_int
    (doc "Absolute value of an Int.")
    (type (fn-type (params (own (con Int))) (ret (own (con Int)))))
    (params x)
    (body
      (if (app lt x 0)
        (app - 0 x)
        x))))
