[plt-scheme] How get name of structure
(define-struct structure1 (f1))
(define-struct structure2 (f1 f2))
(define x (make-structure1 1))
(define y (make-structure2 'a 'b))
(define (f x)
(printf "Name of structure ~a~n"
(regexp-replace* ".*<struct:|>$" (format "~s" x) "")))
(((((lambda(x)((((((((x x)x)x)x)x)x)x)x))
(lambda(x)(lambda(y)(x(x y)))))
(lambda(x)(x)x))
(lambda()(printf "Greetings, Jos~n"))))
----- Original Message -----
From: wwall
To: plt-scheme
Sent: Wednesday, April 11, 2007 9:42 AM
Subject: [plt-scheme] How get name of structure
Hello plt-scheme,
i have this code:
(define-structure structure1 (f1))
(define-structure structure2 (f1 f2))
(define x (make-structure1 1))
(define y (make-structure2 'a 'b))
(define (f x)
(display (format "Name of structure ~a \n" (??? x))))
;call f
(f x)
(f y)
want what will be printed
"Name of structure structure1"
"Name of structure structure2"
what i must write on place "???"
now i write so
(define (??? x) (string->symbol (substring (symbol->string (vector-ref (struct->vector x) 0) ) 12)) )
but think what exists simply method
Thanks
--
Best regards,
wwall mailto:wwall at yandex.ru
_________________________________________________
For list-related administrative tasks:
http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070411/8b9fe4b8/attachment.html>