Carp/examples/sorting.carp
2019-09-17 19:33:08 +02:00

19 lines
423 B
Plaintext

(use Array)
(Project.no-echo)
(deftype Age [x Int])
(defmodule Age
(defn = [a b]
(= (Age.x a) (Age.x b)))
(defn > [a b]
(> (Age.x a) (Age.x b)))
(defn < [a b]
(< (Age.x a) (Age.x b))))
(defn main []
(let-do [ints (Array.sort [10 3 75 40])
ages (Array.sort [(Age.init 10) (Age.init 3) (Age.init 75) (Age.init 40)])]
(IO.println &(Array.str &ints))
(IO.println &(Array.str &ages))))