[mercury-users] unsafe_set_char

James Cussens jc at cs.york.ac.uk
Sat May 29 00:00:33 AEST 2010

Consider the following from the documentation for the string.m library 

   % string.unsafe_set_char(Char, Index, String0, String):
   % This version is constant time, whereas string.set_char_det
   % may be linear in the length of the string. Use with care!

But I can't see how it can be constant time when it involves a call to 
strcpy. I feel I must be missing something here. What's going on?

More generally, being able to destructively update strings would be 
useful, I think. I'm using Mercury to implemenent hidden Markov models 
(which spit out strings) and currently make millions of calls to 
string.unsafe_set_char, so if anyone has tips on quick (perhaps dirty) 
methods of generating strings that would be appreciated. (My initial 
experiments seem to show that using string is better than array(char), btw.)


James Cussens
York Centre for Complex Systems Analysis             jc at cs.york.ac.uk
Department of Biology (Area 17)               Tel  +44 (0)1904 328396
University of York                            Fax  +44 (0)1904 500159
PO Box 373, York YO10 5YW, UK            http://www.cs.york.ac.uk/~jc
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list