From b6b9e6cc05106ed8315b2080832e468c5c54b521 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 12 Jan 2008 12:23:34 -1000 Subject: [PATCH] lint cleanups --- extra/calendar/calendar.factor | 7 ++++--- extra/lazy-lists/lazy-lists.factor | 2 +- extra/opengl/opengl.factor | 2 +- extra/pack/pack.factor | 7 ++----- extra/random-weighted/random-weighted.factor | 2 +- extra/slides/slides.factor | 2 +- extra/tar/tar.factor | 6 +++--- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/extra/calendar/calendar.factor b/extra/calendar/calendar.factor index 9a54608126..4e473279fa 100755 --- a/extra/calendar/calendar.factor +++ b/extra/calendar/calendar.factor @@ -4,7 +4,7 @@ USING: arrays hashtables io io.streams.string kernel math math.vectors math.functions math.parser namespaces sequences strings tuples system debugger combinators vocabs.loader -calendar.backend structs alien.c-types ; +calendar.backend structs alien.c-types math.vectors ; IN: calendar TUPLE: timestamp year month day hour minute second gmt-offset ; @@ -186,7 +186,8 @@ M: number +second ( timestamp n -- timestamp ) #! data tuple-slots { 1 12 365.2425 8765.82 525949.2 31556952.0 } - [ / ] 2map sum ; + v/ sum ; + : dt>months ( dt -- x ) dt>years 12 * ; : dt>days ( dt -- x ) dt>years 365.2425 * ; : dt>hours ( dt -- x ) dt>years 8765.82 * ; @@ -235,7 +236,7 @@ M: timestamp <=> ( ts1 ts2 -- n ) unix-1970 millis 1000 /f seconds +dt ; : now ( -- timestamp ) gmt >local-time ; -: before ( dt -- -dt ) tuple-slots [ neg ] map array>dt ; +: before ( dt -- -dt ) tuple-slots vneg array>dt ; : from-now ( dt -- timestamp ) now swap +dt ; : ago ( dt -- timestamp ) before from-now ; diff --git a/extra/lazy-lists/lazy-lists.factor b/extra/lazy-lists/lazy-lists.factor index a76e0e5f81..1979819dd1 100644 --- a/extra/lazy-lists/lazy-lists.factor +++ b/extra/lazy-lists/lazy-lists.factor @@ -319,7 +319,7 @@ TUPLE: lazy-from-by n quot ; C: lfrom-by lazy-from-by ( n quot -- list ) : lfrom ( n -- list ) - [ 1 + ] lfrom-by ; + [ 1+ ] lfrom-by ; M: lazy-from-by car ( lazy-from-by -- car ) lazy-from-by-n ; diff --git a/extra/opengl/opengl.factor b/extra/opengl/opengl.factor index aabdccd1fb..f611c97209 100644 --- a/extra/opengl/opengl.factor +++ b/extra/opengl/opengl.factor @@ -27,7 +27,7 @@ IN: opengl swap glBegin call glEnd ; inline : do-enabled ( what quot -- ) - over glEnable swap slip glDisable ; inline + over glEnable dip glDisable ; inline : do-matrix ( mode quot -- ) swap [ glMatrixMode glPushMatrix call ] keep diff --git a/extra/pack/pack.factor b/extra/pack/pack.factor index c9d05c19d7..b9b1f6f314 100644 --- a/extra/pack/pack.factor +++ b/extra/pack/pack.factor @@ -2,7 +2,7 @@ USING: alien alien.c-types arrays assocs byte-arrays inference inference.transforms io io.binary io.streams.string kernel math math.parser namespaces parser prettyprint quotations sequences strings threads vectors -words macros ; +words macros math.functions ; IN: pack SYMBOL: big-endian @@ -10,9 +10,6 @@ SYMBOL: big-endian : big-endian? ( -- ? ) 1 *char zero? ; -: clear-bit ( m n -- o ) - 2^ bitnot bitand ; - : >endian ( obj n -- str ) big-endian get [ >be ] [ >le ] if ; inline @@ -88,7 +85,7 @@ M: string b, ( n string -- ) heap-size b, ; "\0" read-until [ drop f ] unless ; : read-c-string* ( n -- str/f ) - read [ 0 = ] right-trim dup empty? [ drop f ] when ; + read [ zero? ] right-trim dup empty? [ drop f ] when ; : (read-128-ber) ( n -- n ) 1 read first diff --git a/extra/random-weighted/random-weighted.factor b/extra/random-weighted/random-weighted.factor index e3c71ec807..1e9e35d0bf 100644 --- a/extra/random-weighted/random-weighted.factor +++ b/extra/random-weighted/random-weighted.factor @@ -4,7 +4,7 @@ USING: kernel namespaces arrays quotations sequences assocs combinators IN: random-weighted -: probabilities ( weights -- probabilities ) dup sum [ / ] curry map ; +: probabilities ( weights -- probabilities ) dup sum v/n ; : layers ( probabilities -- layers ) dup length 1+ [ head ] with map 1 tail [ sum ] map ; diff --git a/extra/slides/slides.factor b/extra/slides/slides.factor index 70a08cdced..ba423699c3 100755 --- a/extra/slides/slides.factor +++ b/extra/slides/slides.factor @@ -85,7 +85,7 @@ TUPLE: slides ; >r first3 r> head 3array ; : strip-tease ( data -- seq ) - dup third length 1 - [ + dup third length 1- [ 2 + (strip-tease) ] with map ; diff --git a/extra/tar/tar.factor b/extra/tar/tar.factor index 01a50566b4..4a737f06c2 100644 --- a/extra/tar/tar.factor +++ b/extra/tar/tar.factor @@ -35,7 +35,7 @@ linkname magic version uname gname devmajor devminor prefix ; : header-checksum ( seq -- x ) 148 cut-slice 8 tail-slice - [ 0 [ + ] reduce ] 2apply + 256 + ; + [ sum ] 2apply + 256 + ; TUPLE: checksum-error ; TUPLE: malformed-block-error ; @@ -164,7 +164,7 @@ TUPLE: unimplemented-typeflag header ; ! Long file name : typeflag-L ( header -- ) [ read-data-blocks ] keep - >string [ CHAR: \0 = ] right-trim filename set + >string [ zero? ] right-trim filename set global [ "long filename: " write filename get . flush ] bind filename get tar-path+ make-directories ; @@ -196,7 +196,7 @@ TUPLE: unimplemented-typeflag header ; ! global [ dup tar-header-name [ print flush ] when* ] bind dup tar-header-typeflag { - { CHAR: \0 [ typeflag-0 ] } + { 0 [ typeflag-0 ] } { CHAR: 0 [ typeflag-0 ] } { CHAR: 1 [ typeflag-1 ] } { CHAR: 2 [ typeflag-2 ] }