Basic types print - vilinski/nemerle GitHub Wiki

Basic types print

  • Category: Arithmetic

  • Description: Basic types print

  • Code:

using System.Console;

def _int = 53;
def _string = "This is a string";
def _char = 'e';
def _bool = true;
def hexint = 0x63;
def octalint = 0o12;
def binaryinteger = 0b110110;
def signedbyte = 81 : sbyte;
def unsignedbyte = 122 : byte;
def smallint = 63 : short;
def smalluint = 61 : ushort;
def integer = 353l;
def usignedint = 351ul;
def nativeint = 7511 : int;
def unsignednativeint = 7653 : uint;
def _long = 12345678912345789L;
def unsignedlong = 12345678912345UL;
def _float = 12.8F;
def _double = 552.8;
def lst = [1, 2, 3];
           
WriteLine("int = {0:d} or {0}", _int);
WriteLine("string = {0:s} or {0}", _string);
WriteLine("char = {0:c} or {0}", _char);
WriteLine("bool = {0:b} or {0}", _bool);
WriteLine("hex int = {0:x} or {0}", hexint);
WriteLine("HEX INT = {0:X} or {0}", hexint);
WriteLine($"oct int = $octalint", octalint);
WriteLine("bin int = {0:d} or {0}", binaryinteger);
WriteLine($"signed byte = $signedbyte");
WriteLine($"unsigned byte = $unsignedbyte");
WriteLine($"small int = $smallint");
WriteLine($"small uint = $smalluint");
WriteLine($"int = $integer", integer);
WriteLine($"uint = $usignedint", usignedint);
WriteLine($"native int = $nativeint"); 
WriteLine($"unsigned native int = $unsignednativeint");
WriteLine("long = {0:d} or {0}", _long);
WriteLine($"unsigned long = $unsignedlong");
WriteLine("float = {0:f} or {0}", _float);
WriteLine("double = {0:f} or {0}", _double);

WriteLine($"splice integer operations = $(integer * 210 + 1)");
WriteLine($"list = ..$lst");
WriteLine($<#list with delimiter = ..$(lst; ";")#>);
WriteLine($<#list with operations = ..$(lst; "; "; x => $"x * 2 = $(x * 2)")#>);
  • Execution Result:
int = 53 or 53
string = This is a string or This is a string
char = e or e
bool = True or True
hex int = 63 or 99
HEX INT = 63 or 99
oct int = 10
bin int = 54 or 54
signed byte = 81
unsigned byte = 122
small int = 63
small uint = 61
int = 353
uint = 351
native int = 7511
unsigned native int = 7653
long = 12345678912345789 or 12345678912345789
unsigned long = 12345678912345
float = 12,80 or 12,8
double = 552,80 or 552,8
splice integer operations = 74131
list = 1, 2, 3
list with delimiter = 1;2;3
list with operations = x * 2 = 2; x * 2 = 4; x * 2 = 6

[Copyright ©](Terms of use, legal notice)