| ... | @@ -101,15 +101,7 @@ pub fn repeat(s: string, times: i32) !string { | ... | @@ -101,15 +101,7 @@ pub fn repeat(s: string, times: i32) !string { |
| 101 | while (i < times) : (i += 1) { | 101 | while (i < times) : (i += 1) { |
| 102 | try list.append(s); | 102 | try list.append(s); |
| 103 | } | 103 | } |
| 104 | return join(list.items, ""); | 104 | return try concat(list.items); |
| 105 | } | | |
| 106 | | | |
| 107 | pub fn join(xs: []string, delim: string) !string { | | |
| 108 | var res: string = ""; | | |
| 109 | for (xs) |x, i| { | | |
| 110 | res = try std.fmt.allocPrint(gpa, "{s}{s}{s}", .{ res, x, if (i < xs.len - 1) delim else "" }); | | |
| 111 | } | | |
| 112 | return res; | | |
| 113 | } | 105 | } |
| 114 | | 106 | |
| 115 | pub fn concat(items: []string) !string { | 107 | pub fn concat(items: []string) !string { |