28 lines
636 B
Plaintext
28 lines
636 B
Plaintext
|
|
namespace Lib =
|
|
|
|
// namespace Internal =
|
|
// function rev(xs, ys) =
|
|
// switch(xs)
|
|
// [] => ys
|
|
// x :: xs => rev(xs, x :: ys)
|
|
private
|
|
function rev(xs, ys) =
|
|
switch(xs)
|
|
[] => ys
|
|
x :: xs => rev(xs, x :: ys)
|
|
|
|
function reverse(xs : list('a)) : list('a) = rev(xs, [])
|
|
|
|
function eqlist(xs : list(int), ys : list(int)) =
|
|
switch((xs, ys))
|
|
([], []) => true
|
|
(x :: xs, y :: ys) => x == y && eqlist(xs, ys)
|
|
_ => false
|
|
|
|
contract TestNamespaces =
|
|
|
|
function palindrome(xs : list(int)) : bool =
|
|
Lib.eqlist(xs, Lib.reverse(xs))
|
|
|