G.3.5 Selecting values from arrays

For the semantics of the parameter ARRY see Conventions of the arrays API.

Function: mbfl_array_left_take DST_ARRY SRC_ARRY NUM_OF_SLOTS
Function: mbfl_array_right_take DST_ARRY SRC_ARRY NUM_OF_SLOTS

Take the leftmost or rightmost NUM_OF_SLOTS values from SRC_ARRY and store them in the leftmost NUM_OF_SLOTS of DST_ARRY.

mbfl_declare_index_array_varref(ARRY, (a b c d e f g h i))
mbfl_declare_index_array_varref(L_RESULT)
mbfl_declare_index_array_varref(R_RESULT)

mbfl_array_left_take  _(L_RESULT) _(ARRY) 3
mbfl_array_right_take _(R_RESULT) _(ARRY) 3

mbfl_slots_qvalues(L_RESULT)    ⇒ a b c
mbfl_slots_qvalues(R_RESULT)    ⇒ g h i
Function: mbfl_array_left_drop DST_ARRY SRC_ARRY NUM_OF_SLOTS
Function: mbfl_array_right_drop DST_ARRY SRC_ARRY NUM_OF_SLOTS

Drop the leftmost or rightmost NUM_OF_SLOTS values from SRC_ARRY and store the remaining values in the leftmost NUM_OF_SLOTS of DST_ARRY.

mbfl_declare_index_array_varref(ARRY, (a b c d e f g h i))
mbfl_declare_index_array_varref(L_RESULT)
mbfl_declare_index_array_varref(R_RESULT)

mbfl_array_left_drop  _(L_RESULT) _(ARRY) 3
mbfl_array_right_drop _(R_RESULT) _(ARRY) 3

mbfl_slots_qvalues(L_RESULT)    ⇒ d e f g h i
mbfl_slots_qvalues(R_RESULT)    ⇒ a b c d e f
Function: mbfl_array_split_at PREFIX_ARRY SUFFIX_ARRY ARRY IDX

Copy values from ARRY to PREFIX_ARRY and SUFFIX_ARRY:

  • values from the range ‘0’ included, IDX excluded are copied to PREFIX_ARRY;
  • values from the range ‘IDX’ included, end are copied to SUFFIX_ARRY.
mbfl_declare_index_array_varref(ARRY, (a b c d e f g h i))
mbfl_declare_index_array_varref(PREFIX)
mbfl_declare_index_array_varref(SUFFIX)

mbfl_array_split_at _(PREFIX) _(SUFFIX) _(ARRY) 4

mbfl_slots_qvalues(PREFIX)      ⇒ a b c d
mbfl_slots_qvalues(SUFFIX)      ⇒ e f g h i

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