For the semantics of the parameter ARRY 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 PRED see Conventions of the arrays API.
Search ARRY for the leftmost/rightmost slot containing a value equal to VALUE according to ISEQUAL. When found: store slot’s index in IDX_RV and return true; otherwise return false.
# 0 1 2 3 4 5 6 7 8 9 mbfl_declare_index_array_varref(ARRY, (a b c 99 d e f 99 g h)) mbfl_declare_integer_varref(IDX) mbfl_array_find_left_slot_containing_value_var _(IDX) _(ARRY) 99 ⇒ 0 $IDX ⇒ 3 mbfl_array_find_right_slot_containing_value_var _(IDX) _(ARRY) 99 ⇒ 0 $IDX ⇒ 7
Like the functions above, but do not retrieve slot’s index.
Search ARRY for the leftmost/rightmost slot containing a value satisfying PRED. When found: store slot’s index in IDX_RV and return true; otherwise return false.
function pred () { mbfl_mandatory_parameter(VALUE, 1, value) mbfl_string_equal "$VALUE" '99' } # 0 1 2 3 4 5 6 7 8 9 mbfl_declare_index_array_varref(ARRY, (a b c 99 d e f 99 g h)) mbfl_declare_integer_varref(IDX) mbfl_array_find_left_slot_satisfying_pred_var _(IDX) _(ARRY) pred ⇒ 0 $IDX ⇒ 3 mbfl_array_find_right_slot_satisfying_pred_var _(IDX) _(ARRY) pred ⇒ 0 $IDX ⇒ 7
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.