1. Rohin Shah
  2. Forth interpreter

Source

Forth interpreter / ANSForth / rvector.bak

#lang racket

; The resizable vector data type.  Must be put into a list to support mutation.

(provide make-rvector rvector-ref rvector-length rvector-set!)

(define (make-rvector size)
  (cons (make-vector size) size))

(define (rvector-ref vlist index)
  (vector-ref (car vlist) index))

(define rvector-length cdr)

(define (rvector-set! vlist index value)
  (if (>= index (rvector-length vlist))
      (let [(old-vec (car vlist))]
        (set-cdr! vlist (max index (* 2 (rvector-length vlist))))
        (set-car! vlist
                  (make-vector (cdr list)))
        (vector-copy! (car vlist) 0 old-vec)))
  (vector-set! (car vlist) index value))