indexing slow-down (i.e., speeding up programs)
Wil Dijkstra
w.dijkstra at scw.vu.nl
Mon Apr 14 06:44:01 EDT 2003
>
> What I need are *absolute* pointers (preferably a memory address, or
> a pointer or a handle to such), rather than the relative (to the
> beginning of the list) pointers given by the line (and possibly ``for
> each'') construct. Arrays presumably would work (but doesn't metacard
> then have to search the indices to resolve the array reference?), and
> reading the million length file into the array just sets the problem
> back one step.
>
> Any suggestions would be appreciated. As I receive the list in
> digest form, if you have a scathingly brilliant idea, please send a
> copy of it directly to my email address. TIA
> --
> John R. Vokey, Ph.D. |\ _,,,---,,_
> Professor /,`.-'`' -. ;-;;,_
> Department of Psychology and Neuroscience |,4- ) )-,_. ,\ ( `'-'
> University of Lethbridge '---''(_/--' `-'\_)
>
Hi John,
May be something like this solves your problem (if I understand your
problem well).
repeat for each line myWord in myDictionnary -- the first list
put 0 into myArray[myWord]
end repeat
repeat for each line myWord in myWordList -- the secondlist
if myArray[myWord] is a number then add 1 to myArray[myWord]
end repeat
The first repeat loop creates an indexed array, using the words
themselves as indexed. These are accessed very fast.
In the second repeat loop MC proceeds through the list using a moving pointer.
The result is an array with each word from your first list as index and
its frequency as content. To get the frequency of "rose", just write:
get myArray["rose"]
Let me know if it works; I'm highly interested in such massive data manipulations.
Wil Dijkstra
More information about the metacard
mailing list