///|
fn pdf_fun_calculator_copy(
  stack : Array[PdfCalculatorValue],
) -> Unit raise @core.PdfError {
  let count = pdf_fun_calculator_pop_int(stack)
  if count < 0 || count > stack.length() {
    raise BadFunctionEvaluation("calculator copy operand out of range")
  }
  let start = stack.length() - count
  let end = stack.length()
  for index in start.. Unit raise @core.PdfError {
  let index = pdf_fun_calculator_pop_int(stack)
  if index < 0 || index >= stack.length() {
    raise BadFunctionEvaluation("calculator index operand out of range")
  }
  stack.push(stack[stack.length() - index - 1])
}

///|
fn pdf_fun_calculator_roll(
  stack : Array[PdfCalculatorValue],
) -> Unit raise @core.PdfError {
  let distance = pdf_fun_calculator_pop_int(stack)
  let count = pdf_fun_calculator_pop_int(stack)
  if count < 1 || count > stack.length() {
    raise BadFunctionEvaluation("calculator roll operand out of range")
  }
  let start = stack.length() - count
  let offset = (distance % count + count) % count
  let rolled : Array[PdfCalculatorValue] = []
  for index in 0..