G.3.7 Inserting values

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

Function: mbfl_array_insert_slot_bang ARRY IDX

Open a slot in ARRY at IDX by shifting values to the right; this function mutates ARRY itself.

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

  mbfl_array_insert_slot_bang _(ARRY) 3
  mbfl_slot_set(ARRY, 3, 99)
  mbfl_slots_qvalues(ARRY)
} ⇒ a b c 99 d e f g h i

{
  mbfl_declare_index_array_varref(ARRY, (a b c))

  mbfl_array_insert_slot_bang _(ARRY) 3
  mbfl_slot_set(ARRY, 3, 99)
  mbfl_slots_qvalues(ARRY)
} ⇒ a b c 99

{
  mbfl_declare_index_array_varref(ARRY)

  mbfl_array_insert_slot_bang _(ARRY) 0
  mbfl_slot_set(ARRY, 0, 99)
  mbfl_slots_qvalues(ARRY)
} ⇒ 99
Function: mbfl_array_insert_value_bang ARRY IDX VALUE

Open a slot in ARRY at IDX by shifting values to the right, then store VALUE in the slot; this function mutates ARRY itself.

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

  mbfl_array_insert_value_bang _(ARRY) 3 99
  mbfl_slots_qvalues(ARRY)
} ⇒ a b c 99 d e f g h i

{
  mbfl_declare_index_array_varref(ARRY, (a b c))

  mbfl_array_insert_value_bang _(ARRY) 3 99
  mbfl_slots_qvalues(ARRY)
} ⇒ a b c 99

{
  mbfl_declare_index_array_varref(ARRY)

  mbfl_array_insert_value_bang _(ARRY) 0 99
  mbfl_slots_qvalues(ARRY)
} ⇒ 99
Function: mbfl_array_insert_multi_slot_bang ARRY IDX NUM

Open NUM slots in ARRY at IDX by shifting the values to the right; this function mutates ARRY itself.

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

mbfl_array_insert_multi_slot_bang _(ARRY) 3 4
mbfl_slot_set(ARRY, 3, 90)
mbfl_slot_set(ARRY, 4, 91)
mbfl_slot_set(ARRY, 5, 92)
mbfl_slot_set(ARRY, 6, 93)
mbfl_slots_qvalues(ARRY)        ⇒ a b c 90 91 92 93 d e f g h i
Function: mbfl_array_insert_multi_value_bang ARRY1 IDX arry2

Open slots in ARRY1 at IDX by shifting values to the right then insert in this range the values from ARRY2; this function mutates ARRY1 itself.

mbfl_declare_index_array_varref(ARRY1, (a b c d e f g h i))
mbfl_declare_index_array_varref(ARRY2, (90 91 92 93))

mbfl_array_insert_multi_slot_bang _(ARRY1) 3 _(ARRY2)
mbfl_slots_qvalues(ARRY1)       ⇒ a b c 90 91 92 93 d e f g h i

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