scsh-0.5/alt/template.scm

22 lines
646 B
Scheme
Raw Permalink Normal View History

1995-10-13 23:34:21 -04:00
; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*-
; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING.
; Templates implemented as vectors.
(define *template-marker* (list '*template-marker*))
(define (make-template len init)
(let ((t (make-vector (+ len 1) init)))
(vector-set! t 0 *template-marker*)
t))
(define (template? obj)
(and (vector? obj)
(> (vector-length obj) 0)
(eq? (vector-ref obj 0) *template-marker*)))
(define (template-length t) (- (vector-length t) 1))
(define (template-ref t i) (vector-ref t (+ i 1)))
(define (template-set! t i x) (vector-set! t (+ i 1) x))