| 95 | } |
| 96 | |
| 97 | Str *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 | |
| 114 | Str *StrJoin(StrArr *arr, const char *sep) { |
| 115 | return StrJoin(arr, sep, strlen(sep)); |
no test coverage detected