]> gitweb.factorcode.org Git - factor.git/commitdiff
add a word to make a sequence from a byte-array by taking n bits at a time
authorDoug Coleman <erg@jobim.local>
Thu, 4 Jun 2009 02:21:51 +0000 (21:21 -0500)
committerDoug Coleman <erg@jobim.local>
Thu, 4 Jun 2009 02:21:51 +0000 (21:21 -0500)
basis/bitstreams/bitstreams.factor

index cb6a753735ca0b7d1f4aebb31129865cadd6559e..4718f137e42188c8018f91171e343896e4bb1fad 100644 (file)
@@ -158,3 +158,9 @@ M: msb0-bit-reader peek ( n bs -- bits ) \ be> \ subseq>bits-be (peek) ;
         writer bytes>> swap push
     ] unless
     writer bytes>> ;
+
+:: byte-array-n>seq ( byte-array n -- seq )
+    byte-array length 8 * n / iota
+    byte-array <msb0-bit-reader> '[
+        drop n _ read
+    ] { } map-as ;