How to spec a vector of custom spec'ed mapsTraversing a list of mapsClojure - extract values from a vector of hashmapsParsing with clojure.specMetaprogramming with clojure.spec values?Exercising macros with named arguments through Clojure SpecClojure Spec for a map with non-keyword keysWhy is Clojure Spec going into an infinite loop here?Clojure: Transform nested maps into custom map keeping only specific attributesClojure Domain Modeling: Spec vs. ProtocolsSyntax error macroexpanding clojure.core/let
Inadvertently nuked my disk permission structure - why?
Does academia have a lazy work culture?
Why was Sauron preparing for war instead of trying to find the ring?
Giant space birds hatching out of planets; short story
Area of parallelogram = Area of square. Shear transform
At what rate does the volume (velocity) of a note decay?
Convert every file from JPEG to GIF in terminal
A planet illuminated by a black hole?
Why isn't there a ";" after "do" in sh loops?
How to judge a Ph.D. applicant that arrives "out of thin air"
Anybody know what this small Nintendo stand is for?
Why are off grid solar setups only 12, 24, 48 VDC?
Spoken encryption
Why did Germany launch its spy satellites from Russia?
AC contactor 1 pole or 2?
TSA asking to see cell phone
What is the difference between 1/3, 1/2, and full casters?
Why not use a diode instead of a resistor for current sense circuits?
How do I generate distribution of positive numbers only with min, max and mean?
Assuring luggage isn't lost with short layover
Examples of simultaneous independent breakthroughs
Why is drive/partition number still used?
How do I stop my characters falling in love?
Is it legal for private citizens to "impound" e-scooters?
How to spec a vector of custom spec'ed maps
Traversing a list of mapsClojure - extract values from a vector of hashmapsParsing with clojure.specMetaprogramming with clojure.spec values?Exercising macros with named arguments through Clojure SpecClojure Spec for a map with non-keyword keysWhy is Clojure Spec going into an infinite loop here?Clojure: Transform nested maps into custom map keeping only specific attributesClojure Domain Modeling: Spec vs. ProtocolsSyntax error macroexpanding clojure.core/let
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a spec for a custom map named ::cell
, let's say
(s/def ::attr-1 int?)
(s/def ::attr-2 int?)
(s/def ::cell :req-un [::attr-1 ::attr-2])
Now I want another spec ::grid
for a custom vector that consists of only these ::cell
maps. As an example, a grid might look like this:
(let grid [:attr-1 11, :attr-2 12 :attr-1 21 :attr-2 22])
Is it possible to create a spec for this requirement using the specification of ::cell
?
(s/def ::grid ???)
clojure clojure.spec
add a comment |
I have a spec for a custom map named ::cell
, let's say
(s/def ::attr-1 int?)
(s/def ::attr-2 int?)
(s/def ::cell :req-un [::attr-1 ::attr-2])
Now I want another spec ::grid
for a custom vector that consists of only these ::cell
maps. As an example, a grid might look like this:
(let grid [:attr-1 11, :attr-2 12 :attr-1 21 :attr-2 22])
Is it possible to create a spec for this requirement using the specification of ::cell
?
(s/def ::grid ???)
clojure clojure.spec
add a comment |
I have a spec for a custom map named ::cell
, let's say
(s/def ::attr-1 int?)
(s/def ::attr-2 int?)
(s/def ::cell :req-un [::attr-1 ::attr-2])
Now I want another spec ::grid
for a custom vector that consists of only these ::cell
maps. As an example, a grid might look like this:
(let grid [:attr-1 11, :attr-2 12 :attr-1 21 :attr-2 22])
Is it possible to create a spec for this requirement using the specification of ::cell
?
(s/def ::grid ???)
clojure clojure.spec
I have a spec for a custom map named ::cell
, let's say
(s/def ::attr-1 int?)
(s/def ::attr-2 int?)
(s/def ::cell :req-un [::attr-1 ::attr-2])
Now I want another spec ::grid
for a custom vector that consists of only these ::cell
maps. As an example, a grid might look like this:
(let grid [:attr-1 11, :attr-2 12 :attr-1 21 :attr-2 22])
Is it possible to create a spec for this requirement using the specification of ::cell
?
(s/def ::grid ???)
clojure clojure.spec
clojure clojure.spec
asked Mar 26 at 17:30
idleherbidleherb
9358 silver badges19 bronze badges
9358 silver badges19 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can use tuple
:
(s/def ::grid (s/tuple ::cell ::cell ::cell))
or coll-of
specifying the kind and count:
(s/coll-of ::cell :kind vector? :count 3)
Thank you! I wasn't aware of the fact that a spec like::grid
could be used as the first argument tos/coll-of
!
– idleherb
Mar 26 at 17:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363047%2fhow-to-spec-a-vector-of-custom-speced-maps%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use tuple
:
(s/def ::grid (s/tuple ::cell ::cell ::cell))
or coll-of
specifying the kind and count:
(s/coll-of ::cell :kind vector? :count 3)
Thank you! I wasn't aware of the fact that a spec like::grid
could be used as the first argument tos/coll-of
!
– idleherb
Mar 26 at 17:41
add a comment |
You can use tuple
:
(s/def ::grid (s/tuple ::cell ::cell ::cell))
or coll-of
specifying the kind and count:
(s/coll-of ::cell :kind vector? :count 3)
Thank you! I wasn't aware of the fact that a spec like::grid
could be used as the first argument tos/coll-of
!
– idleherb
Mar 26 at 17:41
add a comment |
You can use tuple
:
(s/def ::grid (s/tuple ::cell ::cell ::cell))
or coll-of
specifying the kind and count:
(s/coll-of ::cell :kind vector? :count 3)
You can use tuple
:
(s/def ::grid (s/tuple ::cell ::cell ::cell))
or coll-of
specifying the kind and count:
(s/coll-of ::cell :kind vector? :count 3)
answered Mar 26 at 17:39
LeeLee
123k15 gold badges181 silver badges251 bronze badges
123k15 gold badges181 silver badges251 bronze badges
Thank you! I wasn't aware of the fact that a spec like::grid
could be used as the first argument tos/coll-of
!
– idleherb
Mar 26 at 17:41
add a comment |
Thank you! I wasn't aware of the fact that a spec like::grid
could be used as the first argument tos/coll-of
!
– idleherb
Mar 26 at 17:41
Thank you! I wasn't aware of the fact that a spec like
::grid
could be used as the first argument to s/coll-of
!– idleherb
Mar 26 at 17:41
Thank you! I wasn't aware of the fact that a spec like
::grid
could be used as the first argument to s/coll-of
!– idleherb
Mar 26 at 17:41
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363047%2fhow-to-spec-a-vector-of-custom-speced-maps%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown