From e64469788bacccda083a45a709e4b437b00b8270 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 19 May 2015 23:46:30 -0700 Subject: [PATCH] nits --- txexpr/core-predicates.rkt | 3 +++ txexpr/main.rkt | 1 + txexpr/scribblings/txexpr.scrbl | 7 ++++++- txexpr/tests.rkt | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/txexpr/core-predicates.rkt b/txexpr/core-predicates.rkt index 9830c90..0a077b3 100644 --- a/txexpr/core-predicates.rkt +++ b/txexpr/core-predicates.rkt @@ -16,6 +16,9 @@ (define (txexpr-tag? x) (symbol? x)) +(define (txexpr-tags? x) + (and (list? x) (andmap txexpr-tag? x))) + (define (txexpr-attr? x) (match x [(list (? symbol?) (? string?)) #t] diff --git a/txexpr/main.rkt b/txexpr/main.rkt index 2c06c40..4961fe0 100644 --- a/txexpr/main.rkt +++ b/txexpr/main.rkt @@ -8,6 +8,7 @@ [txexpr? predicate/c] [txexpr-short? predicate/c] [txexpr-tag? predicate/c] + [txexpr-tags? predicate/c] [txexpr-attr? predicate/c] [txexpr-attrs? predicate/c] [txexpr-element? predicate/c] diff --git a/txexpr/scribblings/txexpr.scrbl b/txexpr/scribblings/txexpr.scrbl index b31dce2..f032324 100644 --- a/txexpr/scribblings/txexpr.scrbl +++ b/txexpr/scribblings/txexpr.scrbl @@ -137,6 +137,11 @@ Predicates for @racket[_txexpr]s that implement this grammar: @deftogether[( +@defproc[ +(txexpr-tags? +[v any/c]) +boolean?] + @defproc[ (txexpr-attrs? [v any/c]) @@ -147,7 +152,7 @@ boolean?] [v any/c]) boolean?] )] -Shorthand for @code{(listof txexpr-attr?)} and @code{(listof txexpr-element?)}. +Shorthand for @code{(listof txexpr-tag?)}, @code{(listof txexpr-attr?)}, and @code{(listof txexpr-element?)}. diff --git a/txexpr/tests.rkt b/txexpr/tests.rkt index f320836..2ad76a9 100644 --- a/txexpr/tests.rkt +++ b/txexpr/tests.rkt @@ -35,6 +35,9 @@ (check-false (txexpr-tag? "foo")) (check-false (txexpr-tag? 3)) + (check-false (txexpr-tags? 'foo)) + (check-true (txexpr-tags? '(foo bar))) + (check-true (txexpr-attr? '(key "value"))) (check-false (txexpr-attr? '(key "value" "another"))) (check-false (txexpr-attr? '(key 0 "value")))