Created
April 6, 2014 05:45
-
-
Save mduvall/10001961 to your computer and use it in GitHub Desktop.
What's the idiomatic way to concat a bunch of slices?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume the following variables... | |
// r [][]string | |
// s string | |
// p []string | |
// | |
// Problem: append to r the []string x where x is p[1:] + [s] + p[:1] | |
// 1. Do crazy appends | |
r = append(r, append(append(append(make([]string, 0), p[:i]...), s), p[i:]...)) | |
// 2. ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One step closer, still looks a bit unreadable...