<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.38">
<TITLE>Simple Table Update</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Hi,<BR>
<BR>
I'd like to create a new list based on an original list, using information from a second (symbol) list. That second list should be updated as each element in the new list is added. I've been using map a lot, but that's not an option here, and I'm having trouble obtaining a good recursive structure for my function.<BR>
<BR>
The minimal "fixpus" function below shows the problem. I have "sts" on both sides of the ":" list construct, but I'd like the second "sts" to be a version modified by the where (singular) function, "fixpu".<BR>
<BR>
fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit]<BR>
fixpus [] _ = []<BR>
fixpus (pu:pus) sts = fixpu pu sts : fixpus pus sts<BR>
<BR>
where fixpu pu sts = pu<BR>
<BR>
(Below) I tried making "fixpu" return a tuple, and then use "fst", "snd" and "let", but I think it looks strange. I know it's quite basic, but I'd like a strong foundation for what's likely to become a medium-scale project. Can anyone offer advice?<BR>
<BR>
fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit]<BR>
fixpus [] _ = []<BR>
fixpus (pu:pus) sts = let a = (fixpu pu sts) in fst a : fixpus pus (snd a)<BR>
<BR>
where fixpu pu sts = (pu,sts ++ [("",[])])<BR>
<BR>
Regards,<BR>
Paul<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>