G.3.6.1 Comparing two arrays

For the semantics of the parameter ARRY see Conventions of the arrays API. For the semantics of the parameter ARRYS see Conventions of the arrays API. For the semantics of the parameter ISEQUAL see Conventions of the arrays API. For the semantics of the parameter ISLESS see Conventions of the arrays API.

Function: mbfl_array_equal ARRY1 ARRY1
Function: mbfl_array_equal ARRY1 ARRY1 ISEQUAL

Compare the arrays and return true if the elements are equal, slot by slot, according to ISEQUAL; otherwise return false.

mbfl_declare_index_array_varref(ARRY1, (a b c))
mbfl_declare_index_array_varref(ARRY2, (8 9 0))

mbfl_array_equal _(ARRY1) _(ARRY1)
⇒ 0

mbfl_array_equal _(ARRY1) _(ARRY2)
⇒ 1
Function: mbfl_array_less ARRY1 ARRY2
Function: mbfl_array_less ARRY1 ARRY2 ISEQUAL ISLESS

Compare ARRY1 and ARRY2, slot by slot, left to right, and return true if ARRY1 is less than ARRY2 lexicographically; otherwise return false. Values are compared with ISEQUAL and ISLESS. It does not matter if ARRY1 and ARRY2 have the same length or not.

mbfl_declare_index_array_varref(ARRY1, (a b C d e))
mbfl_declare_index_array_varref(ARRY2, (a b c d e))

mbfl_array_less _(ARRY1) _(ARRY1)       ⇒ 1
mbfl_array_less _(ARRY1) _(ARRY2)       ⇒ 0
mbfl_array_less _(ARRY2) _(ARRY1)       ⇒ 1
Function: mbfl_array_greater ARRY1 ARRY2
Function: mbfl_array_greater ARRY1 ARRY2 ISEQUAL ISLESS

Compare ARRY1 and ARRY2, slot by slot, left to right, and return true if ARRY1 is greater than ARRY2 lexicographically; otherwise return false. Values are compared with ISEQUAL and ISLESS. It does not matter if ARRY1 and ARRY2 have the same length or not.

mbfl_declare_index_array_varref(ARRY1, (a b C d e))
mbfl_declare_index_array_varref(ARRY2, (a b c d e))

mbfl_array_greater _(ARRY1) _(ARRY1)    ⇒ 1
mbfl_array_greater _(ARRY1) _(ARRY2)    ⇒ 1
mbfl_array_greater _(ARRY2) _(ARRY1)    ⇒ 0
Function: mbfl_array_leq ARRY1 ARRY2
Function: mbfl_array_leq ARRY1 ARRY2 ISEQUAL ISLESS

Compare ARRY1 and ARRY2, slot by slot, left to right, and return true if ARRY1 is less than or equal to ARRY2 lexicographically; otherwise return false. Values are compared with ISEQUAL and ISLESS. It does not matter if ARRY1 and ARRY2 have the same length or not.

mbfl_declare_index_array_varref(ARRY1, (a b C d e))
mbfl_declare_index_array_varref(ARRY2, (a b c d e))

mbfl_array_leq _(ARRY1) _(ARRY1)        ⇒ 0
mbfl_array_leq _(ARRY1) _(ARRY2)        ⇒ 0
mbfl_array_leq _(ARRY2) _(ARRY1)        ⇒ 1
Function: mbfl_array_geq ARRY1 ARRY2
Function: mbfl_array_geq ARRY1 ARRY2 ISEQUAL ISLESS

Compare ARRY1 and ARRY2, slot by slot, left to right, and return true if ARRY1 is greater than or equal to ARRY2 lexicographically; otherwise return false. Values are compared with ISEQUAL and ISLESS. It does not matter if ARRY1 and ARRY2 have the same length or not.

mbfl_declare_index_array_varref(ARRY1, (a b C d e))
mbfl_declare_index_array_varref(ARRY2, (a b c d e))

mbfl_array_geq _(ARRY1) _(ARRY1)        ⇒ 0
mbfl_array_geq _(ARRY1) _(ARRY2)        ⇒ 1
mbfl_array_geq _(ARRY2) _(ARRY1)        ⇒ 0
Function: mbfl_array_equal_prefix_length_var LEN_RV ARRY1 ARRY2
Function: mbfl_array_equal_prefix_length_var LEN_RV ARRY1 ARRY2 ISEQUAL

Compare ARRY1 and ARRY2, slot by slot, left to right, and store in the result variable LEN_RV the length of the prefix they have in common. Values are compared with ISEQUAL. It does not matter if ARRY1 and ARRY2 have the same length or not.

mbfl_declare_index_array_varref(ARRY1, (a b 9 d e f g h i))
mbfl_declare_index_array_varref(ARRY2, (a b c d e))
mbfl_declare_varref(LEN)

mbfl_array_equal_prefix_length_var _(LEN) _(ARRY1) _(ARRY2)
$LEN    ⇒ 2
Function: mbfl_array_equal_suffix_length_var LEN_RV ARRY1 ARRY2
Function: mbfl_array_equal_suffix_length_var LEN_RV ARRY1 ARRY2 ISEQUAL

Compare ARRY1 and ARRY2, slot by slot, right to left, and store in the result variable LEN_RV the length of the suffix they have in common. Values are compared with ISEQUAL. It does not matter if ARRY1 and ARRY2 have the same length or not.

mbfl_declare_index_array_varref(ARRY1, (a b c d e f g h i))
mbfl_declare_index_array_varref(ARRY2,         (e 9 g h i))
mbfl_declare_varref(LEN)

mbfl_array_equal_suffix_length_var _(LEN) _(ARRY1) _(ARRY2)
$LEN    ⇒ 3

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.