Re: 2 TADS questions
15 Jun 1995 20:00:03 GMT
In article <GDR11.95Jun15093642@stint.cl.cam.ac.uk>,
Gareth Rees <gdr11@cl.cam.ac.uk> wrote:
>Dan Shiovitz <scythe@u.washington.edu> wrote:
>> I think a better way to do it (I've since changed my method, but it's
>> messier), is
>>
>> o := length(self.location.contents);
>> for (i := 1; i < o; ++i)
>> if (cantake self.location.contents[1])
>> self.location.contents[1].moveInto(self);
>
>This fails if any of the calls to cantake fails (the loop spends the
>rest of its time attempting and failing to move the first item in the
>list).
You're right, of course. Ok, I think *this* is correct now:
o := self.location.contents;
for (i := 1; i < length(o); ++i)
if (cantake o[i])
o[i].moveInto(self);
This should solve both the not looping enough times problem, and the if can't
take one of 'em problem.
>--
>Gareth Rees
--
------------------------------------------------+--------------
The Grim Reaper ** scythe@u.washington.edu |
Dan Shiovitz ** shiov@cs.washington.edu | Aude
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Sapere
_Music of the Spheres_ : Coming Nov '95 |
------------------------------------------------+--------------