factor out generating of 'unique' numbers

This commit is contained in:
interp 2003-04-15 13:55:00 +00:00
parent 2ab93f703b
commit 107cb30eb2
2 changed files with 10 additions and 4 deletions

View File

@ -307,6 +307,7 @@
(define-interface surflets/utilities-interface
(export form-query-list
rev-append
generate-unique-number
generate-unique-name))
;; Intelligent Addresses

View File

@ -20,9 +20,14 @@
(rev-app (cdr a) (cons (car a) b))
b)))
;; FIXME: consider creating small names
(define generate-unique-name
;; Every call will surely return another number.
(define generate-unique-number
(let ((id 0))
(lambda (type-string)
(lambda ()
(set! id (+ 1 id))
(string-append type-string (number->string id)))))
id)))
;; FIXME: consider creating small names
(define (generate-unique-name type-string)
(string-append type-string
(number->string (generate-unique-number))))