<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1476" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Dear all,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>I have a problem when I use the memo-function to
implement a dynamic programming algorithm to traverse a graph.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>I use the memo-function in the code
below:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>dynamicPropagationUpAlg cname graph =
let
<BR>
mh
n
= memo h
n<BR>
h
n
=
let<BR>
annotsuccs = (nub (concat (map (memo h) (succs
n))))<BR>
in<BR>
-- When the annotation set of
the<BR>
-- current node is empty, then we have
to<BR>
-- perform
a<BR>
if (length (myannots n) == 0) && ((length annotsuccs) >
1)then<BR>
{- if length (succs n) > 1
then<BR>
error ("<<Annotation failure>> Interface has to be annotated.
"++(show
n))<BR>
else
-}<BR>
case (trace ("Analyzing in component "++cname++"..\n"++"Before renaming
successors annotations\n"++"Check for cycles in: \n"++"Comp:
"++(getCompname n)++" Intf: "++(getIntfname n)++" Inst: "++(getFunname n))
(hasCycleInAnnots annotsuccs))
of<BR>
Nothing -> map
(replaceFunname (getCompname n)(getFunname n))
annotsuccs<BR>
<A href="mailto:jMessage@(Just">jMessage@(Just</A> a) -> error (fromJust
jMessage)<BR>
else<BR>
let<BR>
mergeannots = mergeAnnotSets (annotsuccs++(myannots n)) (myannots
n)<BR>
in<BR>
case (trace ("Analyzing in component "++cname++"..\n"++"After merging successors
annotations\n"++"Check for cycles in: \n"++"Comp: "++(getCompname n)++" Intf:
"++(getIntfname n)++" Inst: "++(getFunname n)) (hasCycleInAnnots
mergeannots))
of<BR>
Nothing ->
mergeannots<BR>
<A href="mailto:jMessage@(Just">jMessage@(Just</A> a) -> error (fromJust
jMessage)<BR>
g <A href="mailto:n@(InterfaceNode">n@(InterfaceNode</A> (annots, bo ,tp)
names) = (InterfaceNode
((memo h n), bo, tp)
names)<BR>
succs
n
= (getSuccsOfNode n
graph)<BR>
myannots (InterfaceNode (annots,b,tp)
names) =
annots<BR>
nodes
= listNodes
graph<BR>
getFunname (InterfaceNode (annots, bo ,tp) (c,t,i)) =
i<BR>
getCompname (InterfaceNode (annots, bo ,tp) (c,t,i)) =
c<BR>
getIntfname (InterfaceNode (annots, bo ,tp) (c,t,i)) =
t<BR>
in<BR>
map (g) nodes<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The idea is that the every node in the graph is
visited only once, moreover that the function "h" is computed only once for
every node.</FONT></DIV>
<DIV><FONT face=Arial size=2>My implementation is not working properly. I don't
know the cause for my problem, so can anyone hint me one the right use of the
memo-function?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks in advance..</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Kind regards,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Tom</DIV></FONT></BODY></HTML>