* symbol-prefix-proc that allows re-prefixing
@ 2004-05-29 12:05 Thien-Thi Nguyen
0 siblings, 0 replies; only message in thread
From: Thien-Thi Nguyen @ 2004-05-29 12:05 UTC (permalink / raw)
Cc: guile-user
example usage:
(use-modules ((database postgres)
#:renamer (symbol-prefix-proc 'PG|||))) ;;; no `cut'
;; => PG|||pg-exec, ...
(use-modules ((database postgres)
#:renamer (symbol-prefix-proc 'PG||| 3))) ;;; `cut'
;; => PG|||exec, ...
(this will appear in guile 1.4.1.99.)
thi
_______________________________________________________________
;; Return a procedure that prefixes its arg (a symbol) with
;; @var{prefix} (also a symbol). Optional arg @var{cut} specifies
;; the number of characters to remove from the head of the original symbol
;; before prefixing (useful for substitution).
;;
;;-sig: (prefix [cut])
;;
(define (symbol-prefix-proc prefix . cut-spec)
;; Insert gratuitous C++ slam here. --ttn
(if (null? cut-spec)
(lambda (symbol)
(symbol-append prefix symbol))
(let ((cut (car cut-spec)))
(lambda (symbol)
(string->symbol
(format #f "~A~A" prefix
(substring (symbol->string symbol) cut)))))))
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-05-29 12:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-29 12:05 symbol-prefix-proc that allows re-prefixing Thien-Thi Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).