[M3devel] m3core: TextCat.m3: MultiCat
    Rodney M. Bates 
    rodney.bates at wichita.edu
       
    Fri Mar  9 23:11:18 CET 2007
    
    
  
It looks wrong to me too.  But once messing with it, how about
treeing the concatenations, something like:
; PROCEDURE MultiCat ( READONLY x : ARRAY OF TEXT ) : TEXT
   = VAR Num := NUMBER ( x )
   ; VAR Half : CARDINAL
   ; BEGIN (* MultiCat *)
       IF Num <= 0
       THEN
         RETURN ""
       ELSIF Num = 1
       THEN
         RETURN x [ 0 ]
       ELSE
         Half := Num DIV 2
       ; RETURN
           Concat
             ( MultiCat ( SUBARRAY ( x , 0 , Half ) )
             , MultiCat ( SUBARRAY ( x , Half , Num - Half ) )
             )
       END (* IF *)
     END MultiCat
It would reduce heap space overhead, allocation time, Multicat
execution time, and maybe collection time (if that has a nonzero
constant factor) from linear to logarithmic.  On the downside,
stack space would increase from constant to logarithmic, which
might hurt in case stack was very tight and heap was not.
dirk muysers wrote:
> ....
>      result := NEW (T, a := x[i], b := result);
> ....
> What about the initialisation of a_len, b_len, and a_or_b_wide ??
> Shouldn't it rather be:
> ....
>      result := Concat (x [i], result)
> ....
> This is almost certainly a bug.
> 
> _________________________________________________________________
> Don't just search. Find. Check out the new MSN Search! 
> http://search.msn.com/
> 
> _______________________________________________
> M3devel mailing list
> M3devel at elegosoft.com
> https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3devel
> 
-- 
-------------------------------------------------------------
Rodney M. Bates, retired assistant professor
Dept. of Computer Science, Wichita State University
Wichita, KS 67260-0083
316-978-3922
rodney.bates at wichita.edu
    
    
More information about the M3devel
mailing list