[Jprogramming] 2 f 3 f 4 f m

Dan Bron jf at dbron.net
Fri May 12 23:03:40 HKT 2006


I didn't realize you also wanted the intermediate results.  The others have provided you answers; but for future reference and exploration:  J provides you many tools.

Here's an (ugly) answer using  ^:  :

	   ug =. 2 : '[: >@:({."1) (2&(u&.>/@:{. , }.)^:(1 < #)^:n @: (; <"_1@:|.)~)'
	
	   L =. 2 4 6 8 10 
	   R =. i. 2 2
	
	   L + ug _  R  NB.  Just final result
	30 31
	32 33
	
	   L + ug a: R NB.  Intermediate results
	 0  1
	 2  3
	
	10 11
	12 13
	
	18 19
	20 21
	
	24 25
	26 27
	
	28 29
	30 31
	
	30 31
	32 33

-Dan  


More information about the Programming mailing list