Created
January 2, 2013 16:28
-
-
Save NN---/4435848 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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