[Oz] Problem using Flatten with FS variables ....
Denys Duchier
Denys.Duchier at ps.uni-sb.de
Thu Mar 2 12:08:45 CET 2000
ravi at konark.ncst.ernet.in (P Ravi Prakash) writes:
> I am having problem using Flatten with finite set variables. The
> following code hangs without printing any output. Could any one point
> out where I am going wrong?
`Flatten' flattens arbitrarily nested lists. This requires a
recursive case analysis to determine whether something is a list or
not. The corresponding case statement blocks on non-determined data
such as fset variables. Below is a version of Flatten that does not
have this problem but is much less efficient. I took the definition
of Flatten from our library and replaced the `case' statement by a
`cond' statement (i.e. uses deep guards).
declare
local
fun {DoFlatten Xs Start End}
cond
X Xr in Xs=X|Xr
then S S1 in
if {DoFlatten X S S1}
then S=Start {DoFlatten Xr S1 End}
else S2 in Start=X|S2 {DoFlatten Xr S2 End}
end
[] Xs=nil then Start=End true
else false
end
end
in
fun {Flatten X}
Start in if {DoFlatten X Start nil} then Start else X end
end
end
--
Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de
Forschungsbereich Programmiersysteme (Programming Systems Lab)
Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier
Postfach 15 11 50 Phone: +49 681 302 5618
66041 Saarbruecken, Germany Fax: +49 681 302 5615
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
More information about the mozart-users
mailing list