More short-circuit updates

db4
Eduardo Cavazos 2008-06-10 20:42:55 -05:00
parent c5cc533182
commit bdd66927fc
8 changed files with 10 additions and 10 deletions

View File

@ -56,7 +56,7 @@ TUPLE: trace-state old new table i j ;
{
[ i>> 0 > ] [ j>> 0 > ]
[ [ old-nth ] [ new-nth ] bi = ]
} <-&& ;
} 1&& ;
: do-retain ( state -- state )
dup old-nth retain boa ,

View File

@ -26,7 +26,7 @@ IN: math.text.english
SYMBOL: and-needed?
: set-conjunction ( seq -- )
first { [ dup 100 < ] [ dup 0 > ] } && and-needed? set drop ;
first { [ dup 100 < ] [ dup 0 > ] } 0&& and-needed? set drop ;
: negative-text ( n -- str )
0 < "Negative " "" ? ;

View File

@ -59,7 +59,7 @@ PRIVATE>
<PRIVATE
: worth-calculating? ( n -- ? )
{ [ dup 1- 3 mod zero? ] [ dup 1- 3 / even? ] } && nip ;
{ [ dup 1- 3 mod zero? ] [ dup 1- 3 / even? ] } 0&& nip ;
PRIVATE>

View File

@ -27,7 +27,7 @@ IN: project-euler.021
: amicable? ( n -- ? )
dup sum-proper-divisors
{ [ 2dup = not ] [ 2dup sum-proper-divisors = ] } && 2nip ;
{ [ 2dup = not ] [ 2dup sum-proper-divisors = ] } 0&& 2nip ;
: euler021 ( -- answer )
10000 [1,b] [ dup amicable? [ drop 0 ] unless ] sigma ;

View File

@ -27,7 +27,7 @@ IN: project-euler.036
: both-bases? ( n -- ? )
{ [ dup palindrome? ]
[ dup >bin dup reverse = ] } && nip ;
[ dup >bin dup reverse = ] } 0&& nip ;
PRIVATE>

View File

@ -47,7 +47,7 @@ IN: project-euler.043
[ 5 4 pick subseq-divisible? ]
[ 3 3 pick subseq-divisible? ]
[ 2 2 pick subseq-divisible? ]
} && nip ;
} 0&& nip ;
PRIVATE>

View File

@ -29,7 +29,7 @@ IN: project-euler.052
[ number>digits natural-sort ] map all-equal? ;
: candidate? ( n -- ? )
{ [ dup odd? ] [ dup 3 mod zero? ] } && nip ;
{ [ dup odd? ] [ dup 3 mod zero? ] } 0&& nip ;
: next-all-same ( x n -- n )
dup candidate? [

View File

@ -19,7 +19,7 @@ strings regexp splitting parser-combinators ascii unicode.case ;
dup [ dupd matches? ] [ drop f ] if
] unless*
]
} && nip ;
} 0&& nip ;
: mark-number ( keyword -- id )
keyword-number? DIGIT and ;
@ -50,7 +50,7 @@ M: rule match-position drop position get ;
[ over matcher-at-line-start? over zero? implies ]
[ over matcher-at-whitespace-end? over whitespace-end get = implies ]
[ over matcher-at-word-start? over last-offset get = implies ]
} && 2nip ;
} 0&& 2nip ;
: rest-of-line ( -- str )
line get position get tail-slice ;
@ -273,7 +273,7 @@ M: mark-previous-rule handle-rule-start
[ check-end-delegate ]
[ check-every-rule ]
[ check-word-break ]
} || drop
} 0|| drop
position inc
mark-token-loop