我想用 oz 语言做一个列表
I want to do a sort of a list with oz language
我想用 oz 语言做一个列表:
但我无法理解
这是我的简单想法,但它是不正确的,你能帮我吗
declare
fun {Permute L }
if L==nil then nil
else L.2.1|L.1|L.2.2
end
end
fun {Trie L }
if L==nil then nil
elseif L.1 < L.2.1 then L
else {Permute L}
end
{Trie L.2 }
end
{Browse {Trie [3 4 2 1 5 ]}}
local
fun {Sort Xs}
fun {BubbleSort Xs}
case Xs
of X1|X2|Xr andthen X2 < X1 then X2|{BubbleSort X1|Xr}
[] X1|X2|Xr andthen X1 =< X2 then X1|{BubbleSort X2|Xr}
[] X|nil then X|nil
end
end
fun {Sort Xs I}
if I > 0 then {Sort {BubbleSort Xs} I-1}
else Xs
end
end
in
{Sort Xs {Length Xs}}
end
in
{Browse {Sort [3 4 2 1 5]}}
end
我想用 oz 语言做一个列表: 但我无法理解 这是我的简单想法,但它是不正确的,你能帮我吗
declare
fun {Permute L }
if L==nil then nil
else L.2.1|L.1|L.2.2
end
end
fun {Trie L }
if L==nil then nil
elseif L.1 < L.2.1 then L
else {Permute L}
end
{Trie L.2 }
end
{Browse {Trie [3 4 2 1 5 ]}}
local
fun {Sort Xs}
fun {BubbleSort Xs}
case Xs
of X1|X2|Xr andthen X2 < X1 then X2|{BubbleSort X1|Xr}
[] X1|X2|Xr andthen X1 =< X2 then X1|{BubbleSort X2|Xr}
[] X|nil then X|nil
end
end
fun {Sort Xs I}
if I > 0 then {Sort {BubbleSort Xs} I-1}
else Xs
end
end
in
{Sort Xs {Length Xs}}
end
in
{Browse {Sort [3 4 2 1 5]}}
end