Reputation:
(define-syntax prnt
(syntax-rules ()
[(prnt elem ...) (display (format "~a" elem ...))]
))
The above code run in racket will emit the following error:
format: format string requires 1 arguments, given 3; arguments were: "~a" "1" 2 3
then how can I achieve when use (prnt "1" 2 3), it can print any thing following prnt?
Upvotes: 2
Views: 410
Reputation: 15769
If you really want a macro:
(define-syntax prnt
(syntax-rules ()
[(prnt elem ...)
(begin (displayln elem) ...)]))
You don't need a macro if all you want is being able to display multiple objects with a single function call, though:
(define (prnt . args)
(for-each displayln args))
Upvotes: 2