G.3.4 Single values operations

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

mbfl_array_insert_value_bang to insert values in a random position.

mbfl_array_remove to remove values in a random position.

Function: mbfl_array_push_front ARRY VALUE

Store VALUE in the leftmost slot of ARRY; this function mutates ARRY itself.

{
  mbfl_declare_index_array_varref(ARRY, ())

  mbfl_array_push_front _(ARRY) '99'
  mbfl_slots_qvalues(ARRY)
} ⇒ 99

{
  mbfl_declare_index_array_varref(ARRY, (A))

  mbfl_array_push_front _(ARRY) '99'
  mbfl_slots_qvalues(ARRY)
} ⇒ 99 A

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

  mbfl_array_push_front _(ARRY) '99'
  mbfl_slots_qvalues(ARRY)
} ⇒ 99 a b c d e f g h i
Function: mbfl_array_push_back ARRY VALUE

Store VALUE in the rightmost slot of ARRY; this function mutates ARRY itself.

{
  mbfl_declare_index_array_varref(ARRY, ())

  mbfl_array_push_back _(ARRY) '99'
  mbfl_slots_qvalues(ARRY)
} ⇒ 99

{
  mbfl_declare_index_array_varref(ARRY, (A))

  mbfl_array_push_back _(ARRY) '99'
  mbfl_slots_qvalues(ARRY)
} ⇒ A 99

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

  mbfl_array_push_back _(ARRY) '99'
  mbfl_slots_qvalues(ARRY)
} ⇒ a b c d e f g h i 99
Function: mbfl_array_pop_front_var VALUE_RV ARRY

Store in the variable VALUE_RV the leftmost value ARRY, then remove that slot from the array; this function mutates ARRY itself. If the array is empty: the behaviour of this function is undefined.

{
  mbfl_declare_index_array_varref(ARRY, (a b c d e))
  mbfl_declare_varref(VALUE)

  mbfl_array_pop_front_var _(VALUE) _(ARRY)
  "$VALUE"                      ⇒ a
  mbfl_slots_qvalues(ARRY)      ⇒ b c d e
}

{
  mbfl_declare_index_array_varref(ARRY, ())
  mbfl_declare_varref(VALUE)

  mbfl_array_pop_front_var _(VALUE) _(ARRY)
  "$VALUE"                      ⇒ a
  mbfl_slots_qvalues(ARRY)      ⇒
}
Function: mbfl_array_pop_back_var VALUE_RV ARRY

Store in the variable VALUE_RV the rightmost value ARRY, then remove that slot from the array; this function mutates ARRY itself. If the array is empty: the behaviour of this function is undefined.

{
  mbfl_declare_index_array_varref(ARRY, (a b c d e))
  mbfl_declare_varref(VALUE)

  mbfl_array_pop_back_var _(VALUE) _(ARRY)
  "$VALUE"                      ⇒ e
  mbfl_slots_qvalues(ARRY)      ⇒ a b c d
}

{
  mbfl_declare_index_array_varref(ARRY, ())
  mbfl_declare_varref(VALUE)

  mbfl_array_pop_back_var _(VALUE) _(ARRY)
  "$VALUE"                      ⇒ a
  mbfl_slots_qvalues(ARRY)      ⇒
}
Function: mbfl_array_front_var VALUE_RV ARRY

Store in the variable VALUE_RV the leftmost value ARRY. If the array is empty: the behaviour of this function is undefined.

{
  mbfl_declare_index_array_varref(ARRY, (a b c d e))
  mbfl_declare_varref(VALUE)

  mbfl_array_front_var _(VALUE) _(ARRY)
  "$VALUE"                      ⇒ a
}
Function: mbfl_array_back_var VALUE_RV ARRY

Store in the variable VALUE_RV the rightmost value ARRY. If the array is empty: the behaviour of this function is undefined.

{
  mbfl_declare_index_array_varref(ARRY, (a b c d e))
  mbfl_declare_varref(VALUE)

  mbfl_array_back_var _(VALUE) _(ARRY)
  "$VALUE"                      ⇒ e
}
Function: mbfl_array_pop_front ARRY

Remove the leftmost slot from the array; this function mutates ARRY itself. If the array is empty: the behaviour of this function is undefined.

{
  mbfl_declare_index_array_varref(ARRY, (a b c d e))

  mbfl_array_pop_front _(VALUE) _(ARRY)
  mbfl_slots_qvalues(ARRY)      ⇒ b c d e
}

{
  mbfl_declare_index_array_varref(ARRY, ())

  mbfl_array_pop_front _(VALUE) _(ARRY)
  mbfl_slots_qvalues(ARRY)      ⇒
}
Function: mbfl_array_pop_back VALUE_RV ARRY

Remove the rightmost slot from the array; this function mutates ARRY itself. If the array is empty: the behaviour of this function is undefined.

{
  mbfl_declare_index_array_varref(ARRY, (a b c d e))

  mbfl_array_pop_back _(VALUE) _(ARRY)
  mbfl_slots_qvalues(ARRY)      ⇒ a b c d
}

{
  mbfl_declare_index_array_varref(ARRY, ())

  mbfl_array_pop_back _(VALUE) _(ARRY)
  mbfl_slots_qvalues(ARRY)      ⇒
}

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