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.
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 can read Oz code ok and appreciate the mastery that some have
with the language, but I'm still not fluent in writing, much less
thinking, in Oz just yet.
Thanks,
Chris Rathman
Filip Konvička wrote:
Hi,
try this in the OPI:
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 {GenerateTail}
choice
nil
[]
_|{GenerateTail}
end
end
fun {GenLists L}
proc {$ Root}
H#T={FindTail L}
in
if {IsDet T} then
Root=L
else
Root=H|{GenerateTail}
end
end
end
Solutions
K
in
Solutions=thread
{Search.all {GenLists a|b|c|_} 1 K}
end
{Inspect Solutions}
{Delay 1000}
{K} %% Kill the search! :-)
end
Why do you need this?
Cheers,
Filip
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users