For the semantics of the parameter ARRY see Conventions of the arrays API. For the semantics of the parameter PRED see Conventions of the arrays API. For the semantics of the parameter ISEQUAL see Conventions of the arrays API.
Copy values from SRC_ARRY to DST_ARRY including only those satisfying PRED.
function pred () { mbfl_mandatory_parameter(X, 1, value) mbfl_declare_varref(Y) mbfl_math_expr_var _(Y) "$X % 2" if (( 0 == Y )) then return_success else return_failure fi } mbfl_declare_index_array_varref(ARRY, (0 1 2 3 4 5 6 7 8 9)) mbfl_declare_index_array_varref(RESULT) mbfl_array_filter _(RESULT) 'pred' _(ARRY) mbfl_slots_qvalues(RESULT) ⇒ 0 2 4 6 8
Copy values from SRC_ARRY to GOOD_ARRY and BAD_ARRY; those satisfying PRED go into GOOD_ARRY, the others go into BAD_ARRY.
function pred () { mbfl_mandatory_parameter(X, 1, value) mbfl_declare_varref(Y) mbfl_math_expr_var _(Y) "$X % 2" if (( 0 == Y )) then return_success else return_failure fi } mbfl_declare_index_array_varref(ARRY, (0 1 2 3 4 5 6 7 8 9)) mbfl_declare_index_array_varref(GOOD_ARRY) mbfl_declare_index_array_varref(BAD_ARRY) mbfl_array_partition _(GOOD_ARRY) _(BAD_ARRY) 'pred' _(ARRY) mbfl_slots_qvalues(GOOD_ARRY) ⇒ 0 2 4 6 8 mbfl_slots_qvalues(BAD_ARRY) ⇒ 1 3 5 7 9
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.