File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 1- def ( xs? length) do:
1+ def xs? length =
22 if xs == () then 0 else 1 + (xs tail length)
33
4- def ( xs? drop n?) do:
4+ def xs? drop n? =
55 match n with:
66 0 => xs
77 n? => xs tail drop n - 1
88
9- def ( xs? take n?) do:
9+ def xs? take n? =
1010 match n with:
1111 0 => ()
1212 n? => xs head :: xs tail take n - 1
1313
14- def ( merge a? b?) do:
14+ def merge a? b? =
1515 match (a, b) with:
1616 (a?, ()) => a
1717 ((), b?) => b
@@ -21,14 +21,14 @@ def (merge a? b?) do:
2121 else
2222 b head :: (merge a b tail)
2323
24- def ( sort items?) do:
24+ def sort items? =
2525 match items with:
2626 () => ()
2727 x? :: () => items
2828 xs? => do:
29- n : = xs length
30- left : = xs take n / 2
31- right : = xs drop n / 2
29+ def n = xs length
30+ def left = xs take n / 2
31+ def right = xs drop n / 2
3232 merge (sort left) (sort right)
3333
3434sort (list 4 7 5 2 3 0 1 9 8 6)
Original file line number Diff line number Diff line change 1- def ( unpack x?) do:
1+ def unpack x? =
22 match x with:
33 i? : Int => "int!"
44 s? : String => "string!"
55
6- MyType : = (Int | String)
7- x : = 1 : MyType
6+ def MyType = (Int | String)
7+ def x = 1 : MyType
88
9- unpack x
9+ println unpack x
You can’t perform that action at this time.
0 commit comments