       }
       res.append(vector.exprs[Int(i)])
       list = next
+    }
+    guard list.isNull else {
+      throw EvalError.typeError(vectors, [.properListType])
     }
     return .makeList(res)
   }

    return .void
  }
  
  func vectorPivot(_ vec: Expr, ilo: Expr, ihi: Expr) throws -> Expr {
    let vector = try vec.vectorAsCollection()
    let hi = try ihi.asInt(below: vector.exprs.count)

    let res = Collection(kind: .vector)
    for expr in exprs {
      res.exprs.append(contentsOf: try expr.vectorAsCollection().exprs)
    }
    return .vector(res)
  }
  
  func vectorConcatenate(_ expr: Expr) throws -> Expr {
    let res = Collection(kind: .vector)
    var list = expr
    while case .pair(let vec, let next) = list {
      res.exprs.append(contentsOf: try vec.vectorAsCollection().exprs)
      list = next
    }
    guard list.isNull else {
      throw EvalError.typeError(expr, [.properListType])
    }
    return .vector(res)
  }
