Merge branch 'master' of git://factorcode.org/git/erg
						commit
						78d5798082
					
				| 
						 | 
				
			
			@ -20,8 +20,6 @@ IN: temporary
 | 
			
		|||
[ 10 ] [ { 1 2 3 4 } [ + ] reduce* ] unit-test
 | 
			
		||||
[ 24 ] [ { 1 2 3 4 } [ * ] reduce* ] unit-test
 | 
			
		||||
 | 
			
		||||
[ 1 2 3 4 ] [ { 1 2 3 4 } 4 nfirst ] unit-test
 | 
			
		||||
 | 
			
		||||
[ -4 ] [ 1 -4 [ abs ] higher ] unit-test
 | 
			
		||||
[ 1 ] [ 1 -4 [ abs ] lower ] unit-test
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -80,4 +78,4 @@ IN: temporary
 | 
			
		|||
{ 13 } [ 1 2 { 3 4 } [ + + ] 2 each-withn + ] unit-test
 | 
			
		||||
[ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test
 | 
			
		||||
 | 
			
		||||
[ 1 2 3 4 ] [ { 1 2 3 4 } 4 nfirst ] unit-test
 | 
			
		||||
[ 1 2 3 4 ] [ { 1 2 3 4 } 4 firstn ] unit-test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,8 +18,9 @@ IN: sequences.lib
 | 
			
		|||
 | 
			
		||||
: map-with2 ( obj obj list quot -- newseq ) 2 map-withn ; inline
 | 
			
		||||
 | 
			
		||||
MACRO: nfirst ( n -- )
 | 
			
		||||
    [ [ swap nth ] curry [ keep ] curry ] map concat [ drop ] compose ;
 | 
			
		||||
MACRO: firstn ( n -- )
 | 
			
		||||
    [ [ swap nth ] curry
 | 
			
		||||
    [ keep ] curry ] map concat [ drop ] compose ;
 | 
			
		||||
 | 
			
		||||
: prepare-index ( seq quot -- seq n quot )
 | 
			
		||||
    >r dup length r> ; inline
 | 
			
		||||
| 
						 | 
				
			
			@ -182,6 +183,14 @@ PRIVATE>
 | 
			
		|||
: ?first3 ( seq -- 1st/f 2nd/f 3rd/f ) dup ?first2 rot ?third ; inline
 | 
			
		||||
: ?first4 ( seq -- 1st/f 2nd/f 3rd/f 4th/f ) dup ?first3 roll ?fourth ; inline
 | 
			
		||||
 | 
			
		||||
USE: continuations
 | 
			
		||||
: ?subseq ( from to seq -- subseq )
 | 
			
		||||
    >r >r 0 max r> r>
 | 
			
		||||
    [ length tuck min >r min r> ] keep subseq ;
 | 
			
		||||
 | 
			
		||||
: ?head* ( seq n -- seq/f ) (head) ?subseq ;
 | 
			
		||||
: ?tail* ( seq n -- seq/f ) (tail) ?subseq ;
 | 
			
		||||
 | 
			
		||||
: accumulator ( quot -- quot vec )
 | 
			
		||||
    V{ } clone [ [ push ] curry compose ] keep ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue