Lurch Deductive Engine

Class

Array

new Array()

The functions below extend the built-in Array class with new functionality.

Source

Methods

static

range() → {array}

An array containing a finite arithmetic sequence of integers.

  • Array.range() returns [ ].
  • Array.range(n) returns [0,1,2,...,n-1].
  • Array.range(a,b) returns [a,a+1,...,b].
  • Array.range(a,b,d) returns the finite arithmetic sequence [a,a+d,...,a+k*d] where $\left|a+kd\right|\leq \left|b\right| < \left|a+(k+1)d\right|$.

Returns

  • array

Source

static

seq(f, a, b) → {array}

An array containing the finite arithmetic sequence, $\left[f(a),f(a+1),\ldots,f(b)\right]$.

Parameters

  • f function

    a univariate function

  • a integer

    the lower index

  • b integer

    the upper index

Returns

  • array

Example

`Array.seq(n=>2*n,3,5)` returns `[6,8,10]`

Source

last() → {*}

The last element of the array, equivalent to A[A.length-1] (if the array is named A)

Returns

  • *

    The last element of the array, or undefined if the array is empty

Source

without(index) → {Array}

Return a shallow copy of the array, but without one (specified) element.

If the given index is not a valid index into the array, then a shallow copy of the array is returned with no change to its elements (all included).

Parameters

  • index number

    Which entry to remove, as a zero-based index

Returns

  • Array

    A shallow copy of the array, but without the element whose index was given

Source