NETSquirrel - guidelines/Printable version


NETSquirrel - guidelines

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/NETSquirrel_-_guidelines

Permission is granted to copy, distribute, and/or modify this document under the terms of the Creative Commons Attribution-ShareAlike 3.0 License.

Introduction

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

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

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:

using NETSquirrel.Extensions;
using NETSquirrel.Utils;

namespace Test
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            BaseTypesUtils.ReadBool("Bool:").PrintLine();
        }
    }
}
{$reference NETSquirrel.dll} 
uses NETSquirrel.Utils;

begin
  BaseTypesUtils.ReadBool('Bool:').PrintLine();
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:

using NETSquirrel.Utils;

namespace Test
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            var x = 1;
            var y = 2;
            BaseTypesUtils.Swap(ref x, ref y); // x == 2, y == 1
        }
    }
}
{$reference NETSquirrel.dll} 
uses NETSquirrel.Utils;

begin
  var x := 1;
  var y := 2;
  BaseTypesUtils.Swap(x, y); // x = 2, y = 1
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:

using NETSquirrel.Extensions;

namespace Test
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            1.To(10).PrintLine(); // 1, 2, ..., 10
            10.DownTo(1).PrintLine(); // 10, 9, ..., 1
            10.ToThis().PrintLine(); // 0, 1, ..., 10
        }
    }
}
{$reference NETSquirrel.dll} 

begin
  1.To(10).PrintLine(); // 1, 2, ..., 10
  10.DownTo(1).PrintLine(); // 1, 2, ..., 10
  10.ToThis().PrintLine(); // 1, 2, ..., 10
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:

using NETSquirrel.Extensions;
using NETSquirrel.Utils;

namespace Test
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            ArraysUtils.GenerateArray(10, i => i).PrintLine(); // 0, 1, ..., 10
            ArraysUtils.GenerateArray(10, 0, x => x + 1).PrintLine(); // 0, 1, ..., 10
        }
    }
}
{$reference NETSquirrel.dll} 
uses NETSquirrel.Utils;

begin
  ArraysUtils.GenerateArray(10, i -> i).PrintLine(); // 0, 1, ..., 10
  ArraysUtils.GenerateArray(10, 0, x -> x + 1).PrintLine(); // 0, 1, ..., 10
end.

GenerateArray usage example 2:

using NETSquirrel.Extensions;
using NETSquirrel.Utils;

namespace Test
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            ArraysUtils.GenerateArray<int>(10, (array, i) => {
                switch (i)
                {
                    case 0:
                    case 1:
                        return 1;
                    default:
                        return array[i - 1] + array[i - 2];
                }
            }).PrintLine(); // 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
        }
    }
}
{$reference NETSquirrel.dll} 
uses NETSquirrel.Utils;
 
begin
  ArraysUtils.GenerateArray&<integer>(10, (a, i) -> begin
    case i of
      0, 1: Result := 1;
      else Result := a[i - 1] + a[i - 2];
    end;
  end).PrintLine(); // 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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 occurred 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:

using NETSquirrel.Extensions;
using NETSquirrel.Utils;

namespace Test
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            ArraysUtils.ReadBoolArray(10, "item {0} = ").PrintLine();
            ArraysUtils.ReadBoolArray(10, i => $"{new[] { "even", "odd" }[i % 2]} item = ").PrintLine();
        }
    }
}
{$reference NETSquirrel.dll}
uses NETSquirrel.Utils;
 
begin
  ArraysUtils.ReadBoolArray(10, 'item {0} = ').PrintLine();
  var lambda: integer -> string := i -> string.Format('{0} item = ', (new string[] ('even', 'odd'))[i mod 2]);
  ArraysUtils.ReadBoolArray(10, lambda).PrintLine();
end.

ReadBoolArray usage example 2:

using NETSquirrel.Extensions;
using NETSquirrel.Utils;

namespace Test
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            ArraysUtils.ReadBoolArray(10, e => e.Message.PrintLine(), "item {0} = ").PrintLine();
            ArraysUtils.ReadBoolArray(10, e => e.Message.PrintLine(),
                i => $"{new[] { "even", "odd" }[i % 2]} item = ").PrintLine();
        }
    }
}
{$reference NETSquirrel.dll}
uses NETSquirrel.Utils;
uses NETSquirrel;
 
begin
  ArraysUtils.ReadBoolArray(10, procedure(e) -> e.Message.PrintLine(), 'item {0} = ').PrintLine();
  ArraysUtils.ReadBoolArray(10, procedure(e) -> e.Message.PrintLine(),
    i -> string.Format('{0} item = ', (new string[] ('even', 'odd'))[i mod 2])).PrintLine();
end.

Working with matrices

edit

Matrices generators

edit

Matrices reading from the keyboard

edit


Medium complexity

Applying data structures interfaces

edit


High complexity

Debug view customization via proxy types

edit


Remarks

Compatibility

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:

{$reference NETSquirrel.dll}
uses NETSquirrel;

begin
  (new integer[] (1, 2, 3)).Numerate().Select(x -> x.index).PrintLine(); // You must use Item2 instead index.
end.


Links

These links are relevant for NETSquirrel.

  1. GitHub
  2. Official site
  3. Support on the Russian VK social media site
  4. Google Docs - Documentation
  5. Cyberforum - theme
  6. Forum of mechanics and mathematics SFU - theme
  7. C# - GeekforGeeks