Skip to content

Instantly share code, notes, and snippets.

@NN---
Created January 2, 2013 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NN---/4435848 to your computer and use it in GitHub Desktop.
Save NN---/4435848 to your computer and use it in GitHub Desktop.
Main() : void
{
def type = "A.B`2+C`1";
def args = ["X", "Y", "Z"].ToList();
def re = Regex(@"`(\d)");
def sp = re.Split(type.Replace('+', '.'), int.MaxValue);
def sb = StringBuilder();
mutable posArg;
for (mutable i = 0; i < sp.Length - 1; i += 2)
{
_ = sb.Append(sp[i]);
def argsNum = int.Parse(sp[i + 1]);
_ = sb.Append("[");
repeat (argsNum)
{
_ = sb.Append(args[posArg]);
_ = sb.Append(",");
posArg++;
}
_ = sb.Remove(sb.Length - 1, 1);
_ = sb.Append("]");
}
WriteLine(sb.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment