Fork me on GitHub
#clojure-spec
<
2017-06-17
>
colinkahn06:06:15

If I have some data like this [:a :b :c :b :a] where the structure is mirrored, but those could be any values, like [:x :y :z :y :x], what would I use from spec to write that?

weavejester15:06:05

@colinkahn: You could have a predicate like #(= % (reverse %))

weavejester15:06:40

(s/and sequential? #(= % (reverse %)))

colinkahn15:06:06

@weavejester thanks, I realized you could do something similar but my solution wasn't as concise 😄

colinkahn15:06:18

is there a more declarative way to define it? I was searching around and found recursive regular expressions with this solution: (\w)(?:(?R)|\w?)\1 But that requires you to be able to reference the group, which I don't see a way to do that with clojure.spec. Maybe using tags?

colinkahn15:06:22

that's from this article: http://www.rexegg.com/regex-recursion.html I know it's for palindromes which wasn't what I originally posted, but curious if you could solve problems in that way using clojure.spec

flyboarder17:06:35

Hello everyone, I have a clojure macro that is in a .clj file, I use this macro within .cljs files however it seems I cannot spec this macro???

matan18:06:32

Can someone kindly explain the point of what is called in spec docs "instrumentation"?

matan18:06:46

I am not sure I get what it is that it actually does, or why it is called that way

matan18:06:32

Aren't args checked anyway, a la :pre ? if not, what is the rationale?!

matan18:06:43

Thanks in advance for clarifying..

weavejester18:06:38

@matan Instrumentation is a little like :pre, except that you can turn it on and off selectively.

weavejester18:06:57

So during development you might have error messages that you do without in production.

mobileink20:06:09

anybody else working on spec-based transformation? use case is representing html head/meta stuff as a clojure map. the task is to transform such a map into html <link>, <meta>, etc. my xform code mimics spec : register a transform for each specked kw, then crawl the validated structure to xform it. this seems like a natural offshoot of spec. i can't be the only person who wants it. what else is out there?

zane21:06:56

Any idea why cljs.spec.test.alpha/check would return a 0-element vector?

zane21:06:02

Seems like cljs.spec.test.alpha/check is #{}. Trying to figure out why that is.

zane22:06:47

What's the recommended way to integrate testing the :ret part of function specs in an automated fashion via clojure.test?