Remove some usages of slip combinators from the core

db4
Slava Pestov 2009-02-05 03:29:59 -06:00
parent 88b401b383
commit 1bbabcd5e1
5 changed files with 12 additions and 11 deletions

View File

@ -42,7 +42,7 @@ SYMBOL: previous
2drop
] [
over previous get conjoin
dup slip
[ call ] keep
[ nip (closure) ] curry assoc-each
] if ; inline recursive

View File

@ -61,9 +61,8 @@ M: decoder stream-read1
: (read) ( n quot -- n string )
over 0 <string> [
[
slip over
[ swapd set-nth-unsafe f ] [ 3drop t ] if
] 2curry find-integer
over [ swapd set-nth-unsafe f ] [ 3drop t ] if
] curry compose find-integer
] keep ; inline
: finish-read ( n string -- string/f )

View File

@ -1,4 +1,4 @@
! Copyright (C) 2004, 2008 Slava Pestov.
! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel.private slots.private math.private
classes.tuple.private ;
@ -227,7 +227,7 @@ PRIVATE>
! Loops
: loop ( pred: ( -- ? ) -- )
dup slip swap [ loop ] [ drop ] if ; inline recursive
[ call ] keep [ loop ] curry when ; inline recursive
: do ( pred body tail -- pred body tail )
over 3dip ; inline

View File

@ -120,7 +120,7 @@ M: float fp-infinity? ( float -- ? )
: iterate-step ( i n quot -- i n quot )
#! Apply quot to i, keep i and quot, hide n.
swap [ 2dup 2slip ] dip swap ; inline
[ nip call ] 3keep ; inline
: iterate-next ( i n quot -- i' n quot ) [ 1+ ] 2dip ; inline
@ -158,7 +158,7 @@ PRIVATE>
over 0 < [
2drop f
] [
2dup 2slip rot [
[ call ] 2keep rot [
drop
] [
[ 1- ] dip find-last-integer

View File

@ -416,7 +416,7 @@ PRIVATE>
over map-into ; inline
: accumulate ( seq identity quot -- final newseq )
swapd [ pick slip ] curry map ; inline
swapd [ [ call ] [ 2drop ] 3bi ] curry map ; inline
: 2each ( seq1 seq2 quot -- )
(2each) each-integer ; inline
@ -825,7 +825,8 @@ PRIVATE>
[ but-last-slice ] [ peek ] bi ; inline
: <flat-slice> ( seq -- slice )
dup slice? [ { } like ] when 0 over length rot <slice> ;
dup slice? [ { } like ] when
[ drop 0 ] [ length ] [ ] tri <slice> ;
inline
<PRIVATE
@ -866,7 +867,8 @@ PRIVATE>
: supremum ( seq -- n ) [ ] [ max ] map-reduce ;
: sigma ( seq quot -- n ) [ 0 ] 2dip [ rot slip + ] curry each ; inline
: sigma ( seq quot -- n )
[ 0 ] 2dip [ dip + ] curry [ swap ] prepose each ; inline
: count ( seq quot -- n ) [ 1 0 ? ] compose sigma ; inline