Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/Optional-parameters/Oz/optional-parameters.oz
Normal file
30
Task/Optional-parameters/Oz/optional-parameters.oz
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
declare
|
||||
class Table
|
||||
attr
|
||||
rows
|
||||
|
||||
meth init(Rows)
|
||||
rows := Rows
|
||||
end
|
||||
|
||||
meth sort(ordering:O<=Lexicographic column:C<=1 reverse:R<=false)
|
||||
fun {Predicate Row1 Row2}
|
||||
Res = {O {Nth Row1 C} {Nth Row2 C}}
|
||||
in
|
||||
if R then {Not Res} else Res end
|
||||
end
|
||||
in
|
||||
rows := {Sort @rows Predicate}
|
||||
end
|
||||
end
|
||||
|
||||
fun {Lexicographic As Bs} %% omitted for brevity
|
||||
end
|
||||
|
||||
T = {New Table init([["a" "b" "c"] ["" "q" "z"] ["zap" "zip" "Zot"]])}
|
||||
in
|
||||
{T sort}
|
||||
{T sort(column:3)}
|
||||
{T sort(column:2)}
|
||||
{T sort(column:2 reverse:true)}
|
||||
{T sort(ordering:fun {$ A B} {Length B} < {Length A} end)}
|
||||
Loading…
Add table
Add a link
Reference in a new issue