I'll have to play with a little more, but it appears close to what I
need - if nothing else it gave me some ideas of where I need to be
looking. One thing I would like is for the retrieval of the items to be
lazy - I may only want the first five choices retrieved. Since it's an
infinite list of choices, don't want to get bogged down in retrieving
the endless tail.
IsDet is the function I was looking for. But I still haven't figured a
way to salvage the pseudo code I gave above. The closest code that I
could juggle in my mind would go something like:
fun {Listo L}
choice
L = nil
[] H T in
L = H|T
H|{Listo T}
end
end
local Z in
{Browse 1#{SolveOne fun {$}{Listo nil} end}}
{Browse 2#{SolveOne fun {$}{Listo 1|2|Z|nil} end}}
{Browse 3#{SolveOne fun {$}{Listo 1|2|Z} end}}
{Browse 4#{SolveTwo fun {$}{Listo 1|2|Z} end}}
{Browse 5#{SolveThree fun {$}{Listo 1|2|Z} end}}
end
The first two work fine but since they are supposed to just echo back
the list, that's not much of an accomplishment. Starting with the
third, it hangs up. Probably just my continued misunderstanding of how
to construct recursive choices.
Well then try the following:
local
fun {FindTail L}
if {IsDet L}==false then
nil#_
else
case L
of nil then
nil#nil
[] H|T then
H2#T2={FindTail T}
in
(H|H2)#T2
end
end
end
fun {GenLists L}
H#T={FindTail L}
in
if {IsDet T} then
[L]
else
fun lazy {GL N}
{Append H {List.make N}}|{GL N+1}
end
in
{GL 0}
end
end
InitSegment={List.take {GenLists a|b|c|_} 5}
in
{Browse InitSegment}
end
As for why I need this? Well, it's an attempt to learn Oz in my
peculiar sort of way. I taught myself ML by working thru CTM, so by my
strange logic, it's only fitting that I learn Oz by reading a book on
Scheme.
:-))
I think that the tutorial is pretty good, maybe it could save you a lot
of time. But by all means, have fun!
Cheers,
Filip
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users