comparison scripts/strings/strjoin.m @ 16761:c6d61dca5acd

* strjoin.m: improve speed of joining long strings
author Stefan Mahr <dac922@gmx.de>
date Tue, 04 Jun 2013 19:40:13 +0200
parents 424463a80134
children 70ea511edbc4
comparison
equal deleted inserted replaced
16760:1c8b6ab2c8ae 16761:c6d61dca5acd
70 "strjoin: the number of delimiters does not match the number of strings") 70 "strjoin: the number of delimiters does not match the number of strings")
71 else 71 else
72 delimiter(end+1) = {""}; 72 delimiter(end+1) = {""};
73 endif 73 endif
74 74
75 rval = sprintf ("%s", [cstr(:).'; delimiter(:).']{:}); 75 rval = [[cstr(:).'; delimiter(:).']{:}];
76 76
77 endfunction 77 endfunction
78 78
79 %!assert (strjoin ({"hello"}, "-"), "hello") 79 %!assert (strjoin ({"hello"}, "-"), "hello")
80 %!assert (strjoin ({"hello", "world"}), "hello world") 80 %!assert (strjoin ({"hello", "world"}), "hello world")