Hey Tzach,If I understand what you're trying to do, you want something like this:[ :uint32:ubyte ;; or bit-seq, depending(delimited-block (prefix uint24 #(- % 5) #(+ % 5))) ]And then you'll need to parse the final block separately. I've left defining the uint24 as an exercise for the reader (sorry, long day), but using (compile-frame [:uint16 :uint8] ...) should be pretty straightforward.
(defn valid-length [l](and (< l 16777216)(>= l 0)))(def uint24 (compile-frame [:ubyte :uint16](fn [u]{:pre [(valid-length u)]}(let [u8 (bit-shift-right u 16)u16 (- u (bit-shift-left u8 16))][u8 u16]))(fn [[u8 u16]]{:post [(valid-length %)]}(+ (bit-shift-left u8 16) u16))))(def avp(compile-frame[:uint32:ubyte(repeated :int32 :prefix (prefix uint24 #(- % 5) #(+ % 5))) ]))
Hope that helps, happy to answer any followup questions.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/NxsCPBk12mE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.