> Yes! what you sent is straigth and simple (and gives 0o664
> permissions) and I don't mind that String.create comes from outside
> the standard library because
> I can rewrite it as
String.create come from the standard library. Not the core one, but
the standard one. You don't have to do anything different for
compiling a program which use any module from the standard library
than for a program which don't use it, so why bother ?
> let string_create pattern size =
> let rec str_cr pattern str size counter =
> if counter < size
> then str_cr pattern (str^pattern) size (counter +1)
> else str
> str_cr pattern "" size 0;;
> (BTW This shouldn't be very performant, fetching arguments around over and
> over should take more memory than marking imperatively the value of a
> counter... I suppose)
you're wrong, you function is tail recursive (it don't do anything
after calling itself), So it don't use the stack.
the real problem is that each time you do a st1 ^ st2 you copy
(length st1) + (length st2) byte in memory. so if I call
string_create "a" 100 it will make (100)*(100 + 1)/2 = 5000 copy of
one byte. String.create 100 will only allocate the 100 byte, it far
(very far) more effective, and in the standard library.