Jump to content

NETSquirrel - guidelines/Low complexity

From Wikibooks, open books for an open world

Working with base types

[edit | edit source]

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 | edit source]
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 | edit source]
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 | edit source]
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 | edit source]

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 | edit source]
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 | edit source]
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 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:

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 | edit source]

Matrices generators

[edit | edit source]

Matrices reading from the keyboard

[edit | edit source]