combinators.extras: Add twice, thrice words.
							parent
							
								
									f9c96628c0
								
							
						
					
					
						commit
						85a3966a9d
					
				| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Doug Coleman
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
! Copyright (C) 2013 Doug Coleman.
 | 
			
		||||
! See http://factorcode.org/license.txt for BSD license.
 | 
			
		||||
USING: tools.test combinators.extras sequences ;
 | 
			
		||||
IN: combinators.extras.tests
 | 
			
		||||
 | 
			
		||||
{ "a b" }
 | 
			
		||||
[ "a" "b" [ " " glue ] once ] unit-test
 | 
			
		||||
 | 
			
		||||
{ "a b c" }
 | 
			
		||||
[ "a" "b" "c" [ " " glue ] twice ] unit-test
 | 
			
		||||
 | 
			
		||||
{ "a b c d" }
 | 
			
		||||
[ "a" "b" "c" "d" [ " " glue ] thrice ] unit-test
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
! Copyright (C) 2013 Doug Coleman.
 | 
			
		||||
! See http://factorcode.org/license.txt for BSD license.
 | 
			
		||||
USING: kernel ;
 | 
			
		||||
IN: combinators.extras
 | 
			
		||||
 | 
			
		||||
: once ( quot -- ) call ; inline
 | 
			
		||||
: twice ( quot -- ) dup [ call ] dip call ; inline
 | 
			
		||||
: thrice ( quot -- ) dup dup [ call ] 2dip [ call ] dip call ; inline
 | 
			
		||||
		Loading…
	
		Reference in New Issue