I am trying to implement quick-sort in Mozart OZ but variable not introduce error comes. I am new with this language. Please help me out.
declare
fun {QuickSort L}
case L
of X|L2 then Left Right SL SR in
{Partition L2 X Left Right}
SL={QuickSort Left}
SR={QuickSort Right}
{Append SL X|SR}
[] nil then nil
end
end
{Browse {QuickSort[4 7 66 545 1 65 22 322]}}
proc {Partition Xs Pivot Left Right}
case Xs
of X|Xr then
if X < Pivot
then Ln in
Left = X | Ln
{Partition Xr Pivot Ln Right}
else Rn in
Right = X | Rn
{Partition Xr Pivot Left Rn}
end
[] nil then Left=nil Right=nil
end
end
fun lazy {LQuickSort Xs}
case Xs of X|Xr then Left Right SortedLeft SortedRight in
{Partition Xr X Left Right}
{LAppend {LQuickSort Left} X|{LQuickSort Right}}
[] nil then nil
end
end