Collections

Collections Arrays

Imported from the upstream Vibescript examples at collections/arrays.vibe and runnable in the browser today.

Reference View source
Source collections/arrays.vibe
# vibe: 0.2

def head(values)
  values[0]
end

def tail(values)
  values[1]
end

def build_matrix(x, y)
  [[x, y], [y, x]]
end

def replace_first(values, value)
  values[0] = value
  values
end

def run
  {
    head: head([10, 20, 30]),
    tail: tail([10, 20, 30]),
    matrix: build_matrix(1, 2),
    replaced: replace_first([1, 2, 3], 99)
  }
end
Output
Press run to execute run from this example.
upstream collections browser-runner