Welcome to the CHICKEN Scheme pasting service

syntax if-keyword? using syntax-rules added by dzoe on Tue May 23 09:33:53 2023

(define-syntax if-identifier?
  (syntax-rules ()
    ((if-symbol? (x . y)  sk fk) fk)
    ((if-symbol? #(x ...) sk fk) fk)
    ((if-symbol? x sk fk)
     (let-syntax ((test (syntax-rules ()
                          ((test x sk* fk*)     sk*)
                          ((test non-x sk* fk*) fk*))))
       (test foo sk fk)))))

(define-syntax if-symbol?
  (syntax-rules (quote)
    ((if-symbol? (quote (x . y)) sk fk) fk)
    ((if-symbol? (quote x) sk fk)
     (let-syntax ((test (syntax-rules ()
                          ((test s sk* fk*)     sk*)
                          ((test non-x sk* fk*) fk*))))
       (test x sk fk)))
    ((if-symbol? (x . y)  sk fk) fk)
    ((if-symbol? #(x ...) sk fk) fk)
    ((if-symbol? x sk fk) fk)))

(define-syntax if-keyword?
  (syntax-rules (quote)
    ((if-symbol? x sk fk)
     (let-syntax ((test (syntax-rules ()
                          ((test x sk* fk*)     sk*)
                          ((test non-x sk* fk*) fk*))))
       (test (quote x) sk fk)))
    ((if-symbol? (x . y)  sk fk) fk)
    ((if-symbol? #(x ...) sk fk) fk)
    ((if-symbol? x sk fk) fk)))

(if-identifier? test (print "identifier") (print "not identifier"))
(if-identifier? 'test (print "identifier") (print "not identifier"))
(if-identifier? 123 (print "identifier") (print "not identifier"))
(if-identifier? "asdf" (print "identifier") (print "not identifier"))
(if-identifier? (a b c) (print "identifier") (print "not identifier"))
(print '---)
(if-symbol? 'test (print "symbol") (print "not symbol"))
(if-symbol? test (print "symbol") (print "not symbol"))
(if-symbol? 123 (print "symbol") (print "not symbol"))
(if-symbol? #:test (print "symbol") (print "not symbol"))
(if-symbol? '(test 12) (print "symbol") (print "not symbol"))
(if-symbol? (test 12) (print "symbol") (print "not symbol"))
(print '---)
(if-keyword? #:test (print "keyword") (print "not keyword"))
(if-keyword? 'test (print "keyword") (print "not keyword"))
(if-keyword? 123 (print "keyword") (print "not keyword"))
(if-keyword? "test" (print "keyword") (print "not keyword"))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the procedure that returns the car of a cdr?
Visually impaired? Let me spell it for you (wav file) download WAV