module InsertionSortBool where
data List (A : Set) : Set where
[] : List A
_∷_ : (x : A) (xs : List A) → List A
infixr 5 _∷_
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
length : ∀{A} → List A → ℕ
length [] = zero
length (x ∷ xs) = suc (length xs)
data Bool : Set where
true false : Bool
if_then_else_ : ∀{A : Set} (b : Bool) (x y : A) → A
if true then x else y = x
if false then x else y = y
infix 0 if_then_else_
_<=_ : ℕ → ℕ → Bool
zero <= m = true
suc n <= zero = false
suc n <= suc m = n <= m
insert : (x : ℕ) (ys : List ℕ) → List ℕ
insert x [] = x ∷ []
insert x (y ∷ ys) = if x <= y then x ∷ y ∷ ys else y ∷ insert x ys
isort : (xs : List ℕ) → List ℕ
isort [] = []
isort (x ∷ xs) = insert x (isort xs)