extra: using empty? in some places.

db4
John Benediktsson 2014-12-04 19:13:08 -08:00
parent 34160212d1
commit 31b22494a1
4 changed files with 11 additions and 13 deletions

View File

@ -46,7 +46,7 @@ M: tcp-echo handle-client*
<tcp-echo> [ <tcp-echo> [
\ threaded-server get server>address binary [ \ threaded-server get server>address binary [
#times [ #bytes read-write ] times #times [ #bytes read-write ] times
contents length 0 = [ incorrect-#bytes ] unless contents empty? [ incorrect-#bytes ] unless
] with-client ] with-client
] with-threaded-server ; ] with-threaded-server ;

View File

@ -31,7 +31,7 @@ IN: fuel.xref
>alist natural-sort ; >alist natural-sort ;
: filter-prefix ( seq prefix -- seq ) : filter-prefix ( seq prefix -- seq )
[ drop-prefix nip length 0 = ] curry filter members ; [ drop-prefix nip empty? ] curry filter members ;
MEMO: (vocab-words) ( name -- seq ) MEMO: (vocab-words) ( name -- seq )
>vocab-link words [ name>> ] map ; >vocab-link words [ name>> ] map ;

View File

@ -65,12 +65,10 @@ SYMBOL: and-needed?
[ " " glue ] unless-empty ; [ " " glue ] unless-empty ;
: append-with-conjunction ( str1 str2 -- newstr ) : append-with-conjunction ( str1 str2 -- newstr )
over length 0 = [ swap [
nip and-needed? get " and " ", " ? glue
] [ and-needed? off
swap and-needed? get " and " ", " ? ] unless-empty ;
glue and-needed? off
] if ;
: (recombine) ( str index seq -- newstr ) : (recombine) ( str index seq -- newstr )
2dup nth 0 = [ 2dup nth 0 = [

View File

@ -144,21 +144,21 @@ M: mdb-collection create-collection ( collection -- )
] bi ; inline ] bi ; inline
: build-collection-map ( -- assoc ) : build-collection-map ( -- assoc )
H{ } clone load-collection-list H{ } clone load-collection-list
[ [ "name" ] dip at "." split second <mdb-collection> ] map [ [ "name" ] dip at "." split second <mdb-collection> ] map
over '[ [ ] [ name>> ] bi _ set-at ] each ; over '[ [ ] [ name>> ] bi _ set-at ] each ;
: ensure-collection-map ( mdb-instance -- assoc ) : ensure-collection-map ( mdb-instance -- assoc )
dup collections>> dup keys length 0 = dup collections>> dup assoc-empty?
[ drop build-collection-map [ >>collections drop ] keep ] [ drop build-collection-map [ >>collections drop ] keep ]
[ nip ] if ; [ nip ] if ;
: (ensure-collection) ( collection mdb-instance -- collection ) : (ensure-collection) ( collection mdb-instance -- collection )
ensure-collection-map [ dup ] dip key? ensure-collection-map [ dup ] dip key?
[ ] [ [ ensure-valid-collection-name ] [ ] [ [ ensure-valid-collection-name ]
[ create-collection ] [ create-collection ]
[ ] tri ] if ; [ ] tri ] if ;
: reserved-namespace? ( name -- ? ) : reserved-namespace? ( name -- ? )
[ "$cmd" = ] [ "system" head? ] bi or ; [ "$cmd" = ] [ "system" head? ] bi or ;