add pending test

This commit is contained in:
Paul Chiusano 2018-09-24 16:30:57 -04:00
parent 31d32bf1d1
commit 45766f0e25

View File

@ -0,0 +1,33 @@
-- > replicate 4 "a"
-- > x = replicate 20 "a"
-- current triggers runtime error
-- java.lang.ClassCastException: org.unisonweb.Builtins$External$$anon$8 cannot be cast to org.unisonweb.Value$Lambda
at org.unisonweb.compilation.package$.org$unisonweb$compilation$package$$$anonfun$dynamicCall$1(compilation.scala:747)
> sort (<) [9234,23,1,3,6,2,3,51,24,1,3,55,2,1]
halveWith : ([a] -> [a] -> b) -> [a] -> b
halveWith k a = k (take (size a / 2) a) (drop (size a / 2) a)
sort : (a -> a -> Boolean) -> [a] -> [a]
sort lte a =
if size a < 2 then a
else halveWith (l r -> merge lte (sort lte l) (sort lte r)) a
merge : (a -> a -> Boolean) -> [a] -> [a] -> [a]
merge lte a b =
use Sequence ++
use Optional None Some
go acc a b = case at 0 a of
None -> acc ++ b
Some hd1 -> case at 0 b of
None -> acc ++ a
Some hd2 ->
if hd1 `lte` hd2 then
go (acc `snoc` hd1) (drop 1 a) b
else
go (acc `snoc` hd2) a (drop 1 b)
go [] a b
()