Hi,
I'm new to Oz and I'm trying to write a simple function which take two
arguments, a list and a boolean,
and switches each couple of elements if they are not in ascending order. If
no switch takes place, the function
must return the initial_list#true otherwise the new_list#false.
Here is my function:
declare
fun{SwitchAndTest Ls Bool}
case Ls of nil then nil#Bool
[] [X] then X|nil#Bool
[] X1|X2|T then
if X1>X2 then X2|{SwitchAndTest (X1|T) false}
else
X1|{SwitchAndTest (X2|T) Bool}
end
end
end
Running {Browse {SwitchAndTest [1 3 2 4 5 6 8 7] true}} returns
1|2|3|4|5|6|7|8|nil#false
instead of [1 2 3 4 5 6 7 8]#false.
It's a newbie question but I couldn't find any solution for now.
Then is there a way to match such an expression in a case statement? I mean
is there a way to write something like
case {SwitchAndTest Ls true} of ANYTHING#false so that it will match
1|2|3|4|5|6|7|8|nil#false ?
Thanks in advance
--
Quirino Zagarese
LaszloItalia Founder (www.laszloitalia.org)
Software Development Manager - Galilaeus s.r.l.
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users