-
Notifications
You must be signed in to change notification settings - Fork 9
Explicitly branching paths
Brian Marick edited this page Mar 20, 2016
·
7 revisions
In a map, you'll often have several keys that use the same checkers. It's a bit annoying to repeat them:
(type! :Point {:x integer?
:y integer?})
You can instead use each-of:
(type! :Point {(each-of :x :y) integer?})
each-of
can also be used within a path:
(type! :Figure {[:points ALL (each-of :x :y)] integer?})
It can also be used in the interior of a path, though I tend use its synonym through-each
for that. The following claims that a :figure
substructure has both :fill
and :line
fields. Each of them has a :color
, which must be an rgb-string?
(type! :X {[:figure (through-each :fill :line) :color] rgb-string?})