Rename reduce-output -> reduce-outputs
							parent
							
								
									fe2a43b481
								
							
						
					
					
						commit
						c8fe4b21e7
					
				| 
						 | 
				
			
			@ -48,7 +48,7 @@ HELP: output>sequence
 | 
			
		|||
    }
 | 
			
		||||
} ;
 | 
			
		||||
 | 
			
		||||
HELP: reduce-output
 | 
			
		||||
HELP: reduce-outputs
 | 
			
		||||
{ $values
 | 
			
		||||
     { "quot" quotation } { "operation" quotation }
 | 
			
		||||
     { "newquot" quotation }
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ HELP: reduce-output
 | 
			
		|||
{ $examples
 | 
			
		||||
    { $example
 | 
			
		||||
        "USING: combinators.smart kernel math prettyprint ;"
 | 
			
		||||
        "3 [ [ 4 * ] [ 4 / ] [ 4 - ] tri ] [ * ] reduce-output ."
 | 
			
		||||
        "3 [ [ 4 * ] [ 4 / ] [ 4 - ] tri ] [ * ] reduce-outputs ."
 | 
			
		||||
        "-9"
 | 
			
		||||
    }
 | 
			
		||||
} ;
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +84,7 @@ ARTICLE: "combinators.smart" "Smart combinators"
 | 
			
		|||
{ $subsection output>sequence }
 | 
			
		||||
{ $subsection output>array }
 | 
			
		||||
"Reducing the output of a quotation:"
 | 
			
		||||
{ $subsection reduce-output }
 | 
			
		||||
{ $subsection reduce-outputs }
 | 
			
		||||
"Summing the output of a quotation:"
 | 
			
		||||
{ $subsection sum-outputs } ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,8 +14,8 @@ IN: combinators.smart.tests
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[ 6 ] [ [ 1 2 3 ] [ + ] reduce-output ] unit-test
 | 
			
		||||
[ 6 ] [ [ 1 2 3 ] [ + ] reduce-outputs ] unit-test
 | 
			
		||||
 | 
			
		||||
[ [ 1 2 3 ] [ + ] reduce-output ] must-infer
 | 
			
		||||
[ [ 1 2 3 ] [ + ] reduce-outputs ] must-infer
 | 
			
		||||
 | 
			
		||||
[ 6 ] [ [ 1 2 3 ] sum-outputs ] unit-test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,8 +15,8 @@ MACRO: input<sequence ( quot -- newquot )
 | 
			
		|||
    [ infer in>> ] keep
 | 
			
		||||
    '[ _ firstn @ ] ;
 | 
			
		||||
 | 
			
		||||
MACRO: reduce-output ( quot operation -- newquot )
 | 
			
		||||
MACRO: reduce-outputs ( quot operation -- newquot )
 | 
			
		||||
    [ dup infer out>> 1 [-] ] dip n*quot compose ;
 | 
			
		||||
 | 
			
		||||
: sum-outputs ( quot -- n )
 | 
			
		||||
    [ + ] reduce-output ; inline
 | 
			
		||||
    [ + ] reduce-outputs ; inline
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue