]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/compression/run-length/run-length.factor
factor: trim using lists
[factor.git] / basis / compression / run-length / run-length.factor
index ce25cd6a63ad2c215bd69ce867c420ac0d0c306d..15380d2ae1a60af67d327c175b7afc94f8a99199 100644 (file)
@@ -1,19 +1,18 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays combinators grouping kernel locals math
-math.matrices math.order multiline sequences.parser sequences
-tools.continuations ;
+USING: arrays combinators grouping kernel math math.matrices
+math.order sequences sequences.parser ;
 IN: compression.run-length
 
 : run-length-uncompress ( byte-array -- byte-array' )
     2 group [ first2 <array> ] map B{ } concat-as ;
 
 : 8hi-lo ( byte -- hi lo )
-    [ HEX: f0 bitand -4 shift ] [ HEX: f bitand ] bi ; inline
+    [ 0xf0 bitand -4 shift ] [ 0xf bitand ] bi ; inline
 
 :: run-length-uncompress-bitmap4 ( byte-array m n -- byte-array' )
     byte-array <sequence-parser> :> sp
-    m  1 + n zero-matrix :> matrix
+    m  1 + n <zero-matrix> :> matrix
     n 4 mod n + :> stride
     0 :> i!
     0 :> j!
@@ -21,7 +20,7 @@ IN: compression.run-length
     [
         ! i j [ number>string ] bi@ " " glue .
         sp next dup 0 = [
-            sp next dup HEX: 03 HEX: ff between? [
+            sp next dup 0x03 0xff between? [
                 nip [ sp ] dip dup odd?
                 [ 1 + take-n but-last ] [ take-n ] if
                 [ j matrix i swap nth copy ] [ length j + j! ] bi
@@ -36,7 +35,7 @@ IN: compression.run-length
             [ sp next 8hi-lo 2array <repetition> concat ] [ head ] bi
             [ j matrix i swap nth copy ] [ length j + j! ] bi
         ] if
-        
+
         ! j stride >= [ i 1 + i!  0 j! ] when
         j stride >= [ 0 j! ] when
         done? not
@@ -45,7 +44,7 @@ IN: compression.run-length
 
 :: run-length-uncompress-bitmap8 ( byte-array m n -- byte-array' )
     byte-array <sequence-parser> :> sp
-    m  1 + n zero-matrix :> matrix
+    m  1 + n <zero-matrix> :> matrix
     n 4 mod n + :> stride
     0 :> i!
     0 :> j!
@@ -53,7 +52,7 @@ IN: compression.run-length
     [
         ! i j [ number>string ] bi@ " " glue .
         sp next dup 0 = [
-            sp next dup HEX: 03 HEX: ff between? [
+            sp next dup 0x03 0xff between? [
                 nip [ sp ] dip dup odd?
                 [ 1 + take-n but-last ] [ take-n ] if
                 [ j matrix i swap nth copy ] [ length j + j! ] bi
@@ -67,7 +66,7 @@ IN: compression.run-length
         ] [
             sp next <array> [ j matrix i swap nth copy ] [ length j + j! ] bi
         ] if
-        
+
         ! j stride >= [ i 1 + i!  0 j! ] when
         j stride >= [ 0 j! ] when
         done? not