MCPcopy Create free account
hub / github.com/Singular/Singular / StrJoin

Function StrJoin

ppcc/adlib/str.cc:97–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97Str *StrJoin(StrArr *arr, const char *sep, Int n) {
98 if (arr->len() == 0)
99 return new Str();
100 Int len = (arr->len() - 1) * n;
101 for (Int i = 0; i < arr->len(); i++) {
102 len += arr->at(i)->len();
103 }
104 Str *result = new Str(len);
105 result->add(arr->first());
106 for (Int i = 1; i < arr->len(); i++) {
107 if (n >= 0)
108 result->add(sep, n);
109 result->add(arr->at(i));
110 }
111 return result;
112}
113
114Str *StrJoin(StrArr *arr, const char *sep) {
115 return StrJoin(arr, sep, strlen(sep));

Callers 8

SFunction · 0.85
SFunction · 0.85
ReadFileFunction · 0.85
NormalizePathFunction · 0.85
RunCPPFunction · 0.85
PassThroughCompilerFunction · 0.85
ExecCompilerFunction · 0.85
MainFunction · 0.85

Calls 5

firstMethod · 0.80
c_strMethod · 0.80
lenMethod · 0.45
atMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected