From: Michal M. <mal...@pl...> - 2003-05-22 18:53:24
|
On Thu, May 22, 2003 at 01:19:21PM -0500, Brian Hurt wrote: > On Thu, 22 May 2003, Remi Vanicat wrote: > > > well, in the original code, one have : > > > > let kmp p = > > let next = init_next p > > and m = String.length p in > > function s -> > > > > So Partial application of the first argument already compute the next > > table. and so you can call the computed function on several different > > string. > > Check. I'd missed that. On the other hand, you compute the length of p > twice- once in kmp and once in init_next. Which is what I was trying to > eliminate. Maybe I was being stupid- how expensive is a String.length? I > was assuming it was O(n), linear with the length of the string. String.length is O(1) (with very small ,,1'' :-) -- : Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv : PLD Linux ::::::::: Wroclaw University, CS Dept : {E-,w}-- {b++,e}>+++ h |