Fork me on GitHub
#clojure
<
2016-12-25
>
roelof09:12:40

How can I make this run so it generates pagenumbers like this "a" "123" and so on

roelof09:12:53

I have now this :

(defn ->long [s] (try (Long/parseLong s) (catch Exception _ ::s/invalid)))

(s/def ::page (s/and (s/conformer ->long) (s/int-in 1 471)))

(s/def ::optional-page (s/nilable ::page))

(defn page-check [page] (let [page page page-num (or (s/conform ::optional-page page) 1)] page-num))

(s/fdef page-check
        :args (string? ::page :page)
        :ret  (number? ::page :page)
        :fn  (s/valid? true?  :page  )
       )  

roelof09:12:52

What do I have to fill in with (s/gen )

seylerius10:12:00

I don't suppose there are any up-to-date DHT/P2P libs for Clojure available? It's looking like I'm probably going to need to just write a damned Pastry wrapper.

seylerius10:12:13

Probably call it Filo

lvh10:12:21

@seylerius +1 a lib called filo should exist.

seylerius10:12:21

I mean, what else would you call a thin clojure wrapper around a lib called pastry?

abdullahibra18:12:00

how can i define my own type which is hash inside hash, then check if the provided hash is hash of hash or not ?

abdullahibra18:12:08

is there good way to do this?

abdullahibra18:12:52

i guess i need to define hash-of-hash type then use instance? method to check the provided hash is hash of hash type or not

abdullahibra18:12:27

(instance? Hash-of-Hash {1 {2 3}}) => should return True

abdullahibra18:12:47

can anybody help me to define this custom type?

abdullahibra18:12:25

#(->> {1 {2 3} 2 {3 4}} (mapv (fn [[k v]] (type v))) (every? (fn [t] (= t clojure.lang.PersistentArrayMap))))

abdullahibra18:12:36

is this elegant solution ?

fellshard18:12:47

#(and (map? %) (every? map? (vals %)))

fellshard18:12:20

"Is the structure itself a map, and are all its values maps?"

abdullahibra18:12:44

(mapv (fn [[k v]] (map? v))) (every? true?))

abdullahibra18:12:51

i didn't know if there is map?

mpenet22:12:05

(s/valid? (s/map-of any? map?) %) with spec

aisamu22:12:50

(prn (type match-pos)) => clojure.lang.LazySeq (prn match-pos) => () (prn (first '()))=> nil (prn (first match-pos)) => java.lang.String cannot be cast to clojure.lang.IFn Why, Lord, why? 😭

tbaldridge23:12:49

@aisamu what's the full stack trace?

tbaldridge23:12:03

it's probably likely that whatever is throwing that error is inside the actual lazy seq, the contents of the lazy seq

tbaldridge23:12:15

would probably throw the same error if you did (first match-pos)