David,
Thanks for responding to Terry's message, with a perfect
diagnosis and explanation.
I have no idea how I allowed this buggy version of listify to get into
or remain in TEACH LISTANSWERS:
> > define listify(list);
> > vars item;
> > [^^(for item in list do [^item] endfor)]
> > enddefine;
I have learnt from bitter experience that I need to test all
demonstration programs even the ones that are *obviously* correct !!.
> The teach file is thus incorrect, and the correct procedure is
>
> define listify1(list);
> vars item;
> [^(for item in list do [^item] endfor)]
> enddefine;
>
> since the single ^ builds the list required without stripping any of the
> brackets inserted in the loop.
Yes, though nowadays I would replace "vars" with "lvars" in that sort of
context.
And, in case anyone doesn't find it obvious, this
[^(for item in list do [^item] endfor)]
is equivalent to this
[% for item in list do [^item] endfor %]
which is probably better style.
> Surprising that no-one's commented before in the 15 years the teach file
> has been around! It must always have produced the error.
I suspect we have a great deal of old teaching material that is not
really used.
> I'll fix it in
> the Sussex masters, though I don't know whether that will propagate now.
I have installed a fixed version in
ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/bugfixes/teach/
with a note in
ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/bugfixes/BUGREPORTS
I shall eventually work out a scheme for updating all the masters and
the gzipped tar files here, but right now I am rather busy with other
things.
It looks as if the bham version will become the "main" version for a
while, though I don't know what will happen in the long run.
Aaron
|