Sebastian Brand wrote: > > > p([1 | PList], DataIn, DataOut) :- !, > update1(PList, PListNext), > ... > p(PListNext, DataNext, DataOut). The reason it is slow is that you don't get indexing because the integer is wrapped inside the list. > > ... > My questions: Is this behaviour to be expected? Are there > improvements I could try? The most straightforward would be something like: iterate_start(DataIn, DataOut) :- PList = [1,2, ... n], %% n is known p(PList, DataIn, DataOut). loop([], Data, Data). loop([I|PList], DataIn, DataOut) :- p(I, PList, PListNext, DataIn, DataNext), loop(PListNext, DataNext, DataOut). p(1, PList, PListNext, DataIn, DataNext) :- update1(PList, PListNext), ... . p(2, PList, PListNext, DataIn, DataNext) :- update2(PList, PListNext), ... . -- Joachim Schimpf / phone: +44 20 7594 8187 IC-Parc, Imperial College / mailto:J.Schimpf@ic.ac.uk London SW7 2AZ, UK / http://www.icparc.ic.ac.uk/eclipseReceived on Mon Feb 04 18:14:34 2002
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:13 PM GMT GMT