NETSquirrel - guidelines

From Wikibooks, open books for an open world
Jump to navigation Jump to search


NETSquirrel - what's that?[edit]

NETSquirrel - it is the library for NET and NETCore which simplifies code writing on NET languages. The idea of creating this library has been come from PABCSystem unit that provides some subroutings for causing some usual operations such as arrays and matrices generation.

Why NETSquirrel?[edit]

NETSquirrel generalizes PABCSystem functionality and adds some itself all over NET. This means that you can safely transfer from PascalABC.NET language to another (ex. C#) and backward.

Namespaces structure[edit]

There are the following namespaces to provide different functionality:

  1. DataStructures - provides non-generic data structures interfaces. Example: IStack interface.
    1. Immutable - provides non-generic immutable data structures interfaces. Example: IImmutableStack interface.
    2. Generic - provides generic data structures interfaces. Example: IStack<T> interface.
      1. Immutable - provides generic immutable data structures interfaces. Example: IImmutableStack<T> interface.
  2. Debug - provides non-generic proxy types for IDE's (such as Visual Studio and Rider) debuggers. Example: CollectionProxyType proxy type.
    1. Generic - provides generic proxy types for IDE's (such as Visual Studio and Rider) debuggers. Example: CollectionProxyType<T> proxy type.
  3. Extensions - provides several extensions for different types. Example: Print extension.
    1. ConsoleSpecific - provides console specific extensions for different types. Example: DebugPrint extension.
  4. Utils - provides several utils for different types. Example: GenerateArray util.

Low complexity[edit]

Working with base types[edit]

You are capable to read values of all over base types and accomplish some extra useful operations with them via NETSquirrel.Utils.BaseTypesUtils and NETSquirrel.Extensions.BaseTypesExtensions classes. Let's consider the provided functionality.

Reading base types values from the keyboard[edit]

Methods
Method's signature Brief description
bool ReadBool(string) Reads the bool value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
byte ReadByte(string) Reads the byte value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
sbyte ReadSByte(string) Reads the sbyte value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
char ReadChar(string) Reads the char value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
decimal ReadDecimal(string) Reads the decimal value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
double ReadDouble(string) Reads the double value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
float ReadFloat(string) Reads the float value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
int ReadInt(string) Reads the int value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
uint ReadUInt(string) Reads the uint value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
long ReadLong(string) Reads the long value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
ulong ReadULong(string) Reads the ulong value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
short ReadShort(string) Reads the short value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
ushort ReadUShort(string) Reads the ushort value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.
string ReadString(string) Reads the string value from the keyboard with the specified prompt and returns it.

Parameters:

  • prompt = "" - describes the prompt to be printed

Notes:

  • If prompt is null then no hint is outputted.

The general idea used in methods names is: ReadTypeName, where TypeName - is the base type's name.

ReadBool usage example:

 1 using NETSquirrel.Extensions;
 2 using NETSquirrel.Utils;
 3 
 4 namespace Test
 5 {
 6     internal static class Program
 7     {
 8         private static void Main(string[] args)
 9         {
10             BaseTypesUtils.ReadBool("Bool:").PrintLine();
11         }
12     }
13 }
1 {$reference NETSquirrel.dll} 
2 uses NETSquirrel.Utils;
3 
4 begin
5   BaseTypesUtils.ReadBool('Bool:').PrintLine();
6 end.

Values swapping[edit]

Methods
Method's signature Brief description
void Swap<T>(ref T, ref T) Swapped two variables values.

Parameters:

  • x - the first value
  • y - the second value

Swap usage example:

 1 using NETSquirrel.Utils;
 2 
 3 namespace Test
 4 {
 5     internal static class Program
 6     {
 7         private static void Main(string[] args)
 8         {
 9             var x = 1;
10             var y = 2;
11             BaseTypesUtils.Swap(ref x, ref y); // x == 2, y == 1
12         }
13     }
14 }
1 {$reference NETSquirrel.dll} 
2 uses NETSquirrel.Utils;
3 
4 begin
5   var x := 1;
6   var y := 2;
7   BaseTypesUtils.Swap(x, y); // x = 2, y = 1
8 end.

Sequences generation from particular ranges[edit]

Extension methods
Method's signature Brief description
bool IsBetween(this int, int, int) Evaluates whether the value passed as this parameter is between two other ones and returns the according bool value.

Parameters:

  • target [this parameter] - the number to be evaluated
  • low - the lowest range's border
  • high - the highest range's border

Notes:

  • The range borders low and high are involved.
IEnumerable<int> To(this int, int) Generates the sequence from the value passed as this parameter to higher one and returns it.

Parameters:

  • from [this parameter] - the lowest sequence number
  • to - the highest sequence's number

Notes:

  • The range borders from and to are involved.
  • If to is lower than from than the empty sequence is returned.
IEnumerable<int> DownTo(this int, int) Generates the sequence from the value passed as this parameter to lower one and returns it.

Parameters:

  • from [this parameter] - the highest sequence number
  • to - the lowest sequence's number

Notes:

  • The range borders from and to are involved.
  • If to is higher than from than the empty sequence is returned.
IEnumerable<int> ToThis(this int) Generates the sequences from 0 up to/down to (dependent on the second value) to the value passed as this parameter and returns it.

Parameters:

  • to [this parameter] - the last sequence number

Notes:

  • The range borders 0 and to are involved.
IEnumerable<int> Stepped(this int, int) Generates the endless sequence from the value passed as this parameter with the specified step and returns it.

Parameters:

  • from [this parameter] - the first sequence number
  • step - the sequence's step

Notes:

  • The lowest border from is involved.
bool Print() Outputs bool typed value.

Parameters:

  • item [this parameter] - the value to be printed
bool PrintLine() Outputs bool typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
byte Print() Outputs byte typed value.

Parameters:

  • item [this parameter] - the value to be printed
byte PrintLine() Outputs byte typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
sbyte Print() Outputs sbyte typed value.

Parameters:

  • item [this parameter] - the value to be printed
sbyte PrintLine() Outputs sbyte typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
char Print() Outputs char typed value.

Parameters:

  • item [this parameter] - the value to be printed
char PrintLine() Outputs char typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
decimal Print() Outputs decimal typed value.

Parameters:

  • item [this parameter] - the value to be printed
decimal PrintLine() Outputs decimal typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
double Print() Outputs double typed value.

Parameters:

  • item [this parameter] - the value to be printed
double PrintLine() Outputs double typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
float Print() Outputs float typed value.

Parameters:

  • item [this parameter] - the value to be printed
float PrintLine() Outputs float typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
int Print() Outputs int typed value.

Parameters:

  • item [this parameter] - the value to be printed
int PrintLine() Outputs int typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
uint Print() Outputs uint typed value.

Parameters:

  • item [this parameter] - the value to be printed
uint PrintLine() Outputs uint typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
long Print() Outputs long typed value.

Parameters:

  • item [this parameter] - the value to be printed
long PrintLine() Outputs long typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
ulong Print() Outputs ulong typed value.

Parameters:

  • item [this parameter] - the value to be printed
ulong PrintLine() Outputs ulong typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
short Print() Outputs short typed value.

Parameters:

  • item [this parameter] - the value to be printed
short PrintLine() Outputs short typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed
ushort Print() Outputs ushort typed value.

Parameters:

  • item [this parameter] - the value to be printed
ushort PrintLine() Outputs ushort typed value and jumps onto the new line.

Parameters:

  • item [this parameter] - the value to be printed

To, DownTo and ToThis usage example:

 1 using NETSquirrel.Extensions;
 2 
 3 namespace Test
 4 {
 5     internal static class Program
 6     {
 7         private static void Main(string[] args)
 8         {
 9             1.To(10).PrintLine(); // 1, 2, ..., 10
10             10.DownTo(1).PrintLine(); // 10, 9, ..., 1
11             10.ToThis().PrintLine(); // 0, 1, ..., 10
12         }
13     }
14 }
1 {$reference NETSquirrel.dll} 
2 
3 begin
4   1.To(10).PrintLine(); // 1, 2, ..., 10
5   10.DownTo(1).PrintLine(); // 1, 2, ..., 10
6   10.ToThis().PrintLine(); // 1, 2, ..., 10
7 end.

Working with arrays[edit]

You are capable to read arrays of all over base types and accomplish some extra useful operations with them via NETSquirrel.Utils.ArrayUtils class. Let's consider the provided functionality.

Arrays generators[edit]

Methods
Method's signature Brief description
T[] GenerateArray<T>(int, Func<int, T>, int) Generates the array with specified length via particular selector and returns it.

Parameters:

  • count - the array's length
  • selector - the delegate instance that projects each index to some value
  • firstIndex - the indices shift

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If selector is null then ArgumentNullException is thrown.

Notes:

  • Every index i from 0..count range is mapped to the concrete i-th value.
T[] GenerateArray<T>(int, T, Func<T, T>) Generates the array with specified length via particular selector and returns it.

Parameters:

  • count - the array's length
  • first - the first array's value
  • selector - the delegate instance that retrieves the next item from the previous one

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If next is null then ArgumentNullException is thrown.
T[] GenerateArray<T>(int, Func<T[], int, T>) Generates the array with specified length via particular selector and returns it.

Parameters:

  • count - the array's length
  • selector - the delegate instance that retrieves the next item based on previous ones

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If selector is null then ArgumentNullException is thrown.

Notes:

  • Delegate's array (first) parameter is used to refer to the array that is creating.
  • Delegate's index (second) parameter is used to refer to the i-th value to be set.
int[] CreateRandomIntArray(int, int, int) Creates the randomly filled array with values taken from the particular range.

Parameters:

  • count - the array's length
  • low [optional parameter], default value = 0 - determines the lowest range's border
  • high [optional parameter], default value = int.MaxValue - determines the highest range's border

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If low > high then ArgumentOutOfRangeException is thrown.
float[] CreateRandomFloatArray(int, float, float) Creates the randomly filled array with values taken from the particular range.

Parameters:

  • count - the array's length
  • low [optional parameter], default value = 0 - determines the lowest range's border
  • high [optional parameter], default value = float.MaxValue - determines the highest range's border

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If low > high then ArgumentOutOfRangeException is thrown.

GenerateArray usage example:

 1 using NETSquirrel.Extensions;
 2 using NETSquirrel.Utils;
 3 
 4 namespace Test
 5 {
 6     internal static class Program
 7     {
 8         private static void Main(string[] args)
 9         {
10             ArraysUtils.GenerateArray(10, i => i).PrintLine(); // 0, 1, ..., 10
11             ArraysUtils.GenerateArray(10, 0, x => x + 1).PrintLine(); // 0, 1, ..., 10
12         }
13     }
14 }
1 {$reference NETSquirrel.dll} 
2 uses NETSquirrel.Utils;
3 
4 begin
5   ArraysUtils.GenerateArray(10, i -> i).PrintLine(); // 0, 1, ..., 10
6   ArraysUtils.GenerateArray(10, 0, x -> x + 1).PrintLine(); // 0, 1, ..., 10
7 end.

GenerateArray usage example 2:

 1 using NETSquirrel.Extensions;
 2 using NETSquirrel.Utils;
 3 
 4 namespace Test
 5 {
 6     internal static class Program
 7     {
 8         private static void Main(string[] args)
 9         {
10             ArraysUtils.GenerateArray<int>(10, (array, i) => {
11                 switch (i)
12                 {
13                     case 0:
14                     case 1:
15                         return 1;
16                     default:
17                         return array[i - 1] + array[i - 2];
18                 }
19             }).PrintLine(); // 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
20         }
21     }
22 }
 1 {$reference NETSquirrel.dll} 
 2 uses NETSquirrel.Utils;
 3  
 4 begin
 5   ArraysUtils.GenerateArray&<integer>(10, (a, i) -> begin
 6     case i of
 7       0, 1: Result := 1;
 8       else Result := a[i - 1] + a[i - 2];
 9     end;
10   end).PrintLine(); // 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
11 end.

Arrays reading from the keyboard[edit]

Method's name Brief description
bool[] ReadBoolArray(int, string) Reads the array of bool[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
bool[] ReadBoolArray(int, Func<int, string>) Reads the array of bool[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
bool[] ReadBoolArray(int, ExceptionHandler, string) Reads the array of bool[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
bool[] ReadBoolArray(int, ExceptionHandler, Func<int, string>) Reads the array of bool[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
byte[] ReadByteArray(int, string) Reads the array of byte[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
byte[] ReadByteArray(int, Func<int, string>) Reads the array of byte[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
byte[] ReadByteArray(int, ExceptionHandler, string) Reads the array of byte[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
byte[] ReadByteArray(int, ExceptionHandler, Func<int, string>) Reads the array of byte[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
sbyte[] ReadSByteArray(int, string) Reads the array of sbyte[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
sbyte[] ReadSByteArray(int, Func<int, string>) Reads the array of sbyte[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
sbyte[] ReadSByteArray(int, ExceptionHandler, string) Reads the array of sbyte[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
sbyte[] ReadSByteArray(int, ExceptionHandler, Func<int, string>) Reads the array of sbyte[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
char[] ReadCharArray(int, string) Reads the array of char[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
char[] ReadCharArray(int, Func<int, string>) Reads the array of char[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
decimal[] ReadDecimalArray(int, string) Reads the array of decimal[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
decimal[] ReadDecimalArray(int, Func<int, string>) Reads the array of decimal[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
decimal[] ReadDecimalArray(int, ExceptionHandler, string) Reads the array of decimal[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
decimal[] ReadDecimalArray(int, ExceptionHandler, Func<int, string>) Reads the array of decimal[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
double[] ReadDooubleArray(int, string) Reads the array of double[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
double[] ReadDooubleArray(int, Func<int, string>) Reads the array of double[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
double[] ReadDooubleArray(int, ExceptionHandler, string) Reads the array of double[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
double[] ReadDooubleArray(int, ExceptionHandler, Func<int, string>) Reads the array of double[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
float[] ReadFloatArray(int, string) Reads the array of float[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
float[] ReadFloatArray(int, Func<int, string>) Reads the array of float[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
float[] ReadFloatArray(int, ExceptionHandler, string) Reads the array of float[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
float[] ReadFloatArray(int, ExceptionHandler, Func<int, string>) Reads the array of float[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
int[] ReadIntArray(int, string) Reads the array of int[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
int[] ReadIntArray(int, Func<int, string>) Reads the array of int[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
int[] ReadIntArray(int, ExceptionHandler, string) Reads the array of int[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
int[] ReadIntArray(int, ExceptionHandler, Func<int, string>) Reads the array of int[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
uint[] ReadUIntArray(int, string) Reads the array of uint[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
uint[] ReadUIntArray(int, Func<int, string>) Reads the array of uint[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
uint[] ReadUIntArray(int, ExceptionHandler, string) Reads the array of uint[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
uint[] ReadUIntArray(int, ExceptionHandler, Func<int, string>) Reads the array of uint[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
long[] ReadLongArray(int, string) Reads the array of long[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
long[] ReadLongArray(int, Func<int, string>) Reads the array of long[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
long[] ReadLongArray(int, ExceptionHandler, string) Reads the array of long[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
long[] ReadLongArray(int, ExceptionHandler, Func<int, string>) Reads the array of long[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
ulong[] ReadULongArray(int, string) Reads the array of ulong[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
ulong[] ReadULongArray(int, Func<int, string>) Reads the array of ulong[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
ulong[] ReadULongArray(int, ExceptionHandler, string) Reads the array of ulong[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
ulong[] ReadULongArray(int, ExceptionHandler, Func<int, string>) Reads the array of ulong[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
short[] ReadShortArray(int, string) Reads the array of short[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
short[] ReadShortArray(int, Func<int, string>) Reads the array of short[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
short[] ReadShortArray(int, ExceptionHandler, string) Reads the array of short[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
short[] ReadShortArray(int, ExceptionHandler, Func<int, string>) Reads the array of short[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
ushort[] ReadUShortArray(int, string) Reads the array of ushort[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
ushort[] ReadUShortArray(int, Func<int, string>) Reads the array of ushort[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
ushort[] ReadUShortArray(int, ExceptionHandler, string) Reads the array of ushort[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
ushort[] ReadUShortArray(int, ExceptionHandler, Func<int, string>) Reads the array of ushort[] type with the specified length.

Parameters:

  • count - the array's length
  • handler - the exception's handler
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
  • If handler is null then the occured exception is not handled.
string[] ReadStringArray(int, string) Reads the array of string[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat = "item {0}:" - the prompt's format

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.
string[] ReadStringArray(int, Func<int, string>) Reads the array of string[] type with the specified length.

Parameters:

  • count - the array's length
  • promptFormat - the delegate instance which specified prompt's format for each array's item

Exceptions:

  • If count < 0 then ArgumentOutOfRangeException is thrown.
  • If promptFormat is null then ArgumentNullException is thrown.

Notes:

  • promptFormat parameter is used for reading each array item.

ReadBoolArray usage example:

 1 using NETSquirrel.Extensions;
 2 using NETSquirrel.Utils;
 3 
 4 namespace Test
 5 {
 6     internal static class Program
 7     {
 8         private static void Main(string[] args)
 9         {
10             ArraysUtils.ReadBoolArray(10, "item {0} = ").PrintLine();
11             ArraysUtils.ReadBoolArray(10, i => $"{new[] { "even", "odd" }[i % 2]} item = ").PrintLine();
12         }
13     }
14 }
1 {$reference NETSquirrel.dll}
2 uses NETSquirrel.Utils;
3  
4 begin
5   ArraysUtils.ReadBoolArray(10, 'item {0} = ').PrintLine();
6   var lambda: integer -> string := i -> string.Format('{0} item = ', (new string[] ('even', 'odd'))[i mod 2]);
7   ArraysUtils.ReadBoolArray(10, lambda).PrintLine();
8 end.

ReadBoolArray usage example 2:

 1 using NETSquirrel.Extensions;
 2 using NETSquirrel.Utils;
 3 
 4 namespace Test
 5 {
 6     internal static class Program
 7     {
 8         private static void Main(string[] args)
 9         {
10             ArraysUtils.ReadBoolArray(10, e => e.Message.PrintLine(), "item {0} = ").PrintLine();
11             ArraysUtils.ReadBoolArray(10, e => e.Message.PrintLine(),
12                 i => $"{new[] { "even", "odd" }[i % 2]} item = ").PrintLine();
13         }
14     }
15 }
1 {$reference NETSquirrel.dll}
2 uses NETSquirrel.Utils;
3 uses NETSquirrel;
4  
5 begin
6   ArraysUtils.ReadBoolArray(10, procedure(e) -> e.Message.PrintLine(), 'item {0} = ').PrintLine();
7   ArraysUtils.ReadBoolArray(10, procedure(e) -> e.Message.PrintLine(),
8     i -> string.Format('{0} item = ', (new string[] ('even', 'odd'))[i mod 2])).PrintLine();
9 end.

Working with matrices[edit]

Matrices generators[edit]

Matrices reading from the keyboard[edit]

Medium complexity[edit]

Applying data structures interfaces[edit]

High complexity[edit]

Debug view customization via proxy types[edit]

Remarks[edit]

There is no full compatibility between NETSquirrel and PascalABC.NET due to named tuples usage. It means that the following code will not compile:

1 {$reference NETSquirrel.dll}
2 uses NETSquirrel;
3 
4 begin
5   (new integer[] (1, 2, 3)).Numerate().Select(x -> x.index).PrintLine(); // You must use Item2 instead index.
6 end.

Links[edit]

  1. GitHub
  2. Official site
  3. Support
  4. Cyberforum - theme
  5. Forum of mechanics and mathematics SFU - theme

See also[edit]

  1. C# - GeekforGeeks