Skip to content

Instantly share code, notes, and snippets.

@stdray
Created January 15, 2015 15:10
Show Gist options
  • Select an option

  • Save stdray/ff84091ad8f9cc575c78 to your computer and use it in GitHub Desktop.

Select an option

Save stdray/ff84091ad8f9cc575c78 to your computer and use it in GitHub Desktop.
using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;
using System;
using System.Collections.Generic;
using System.Console;
using System.Linq;
module Program
{
Main() : void
{
PrintTypeString(typeof(List[Dictionary[int, _]]));
_ = ReadLine();
}
TypeString(type : Type) : string
{
if(type.IsArray)
{
def et = type.GetElementType();
$"array[$(TypeString(et))]"
}
else if(type.GenericTypeArguments.Length > 0)
{
def argsStr = string.Join(", ", type.GenericTypeArguments.Map(TypeString));
$"$(type.Name)[$argsStr]"
}
else type.Name
}
PrintTypeString(type : Type) : void
{
Console.WriteLine(TypeString(type))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment