as a test function

Volume =: 3 : '''Volume is :'', (": l*w*h), '' for length '', (": l) , '' width 
'' , (": w) , '' and height '' , (": h) [''l w h'' =. y'

   Volume 3 4 5 
Volume is :60 for length 3 width 4 and height 5

some functions for currying arbitrary parameters
 
hook =: 2 : '([: u v) : (u v) ' 
itemamend =: 4 : '((2}.$y) $"1 0 x)} y' 
filtermodA =: 1 : 'u itemamend ] ,:  (#inv~ u)' 
curry =: 4 : '(boxopen y) (a: = ]) filtermodA x' 
curryB=: 2 : 'u hook (n&curry)'

This works: curry height to 4, and then in returned function, curry length to 3
   Volume curryB ( a:, a:,<4) curryB (3;a:) 
([: ([: Volume ((0$0);(0$0);4)&curry) :(Volume ((0$0);(0$0);4)&curry) 
(3;0$0)&curry) :(([: Volume ((0$0);(0$0);4)&curry) :(Volume 
((0$0);(0$0);4)&curry) (3;0$0)&curry) 


 calling with remaining parameter (width) 2 returns as desired

   Volume curryB ( a:, a:,<4) curryB (3;a:) 2 
Volume is :24 for length 3 width 2 and height 4 

it also works as a dyadic call

  Volume@:] curryB ( a:, a:,<4) curryB (3;a:) 2 
Volume is :24 for length 3 width 2 and height 4 
  2 Volume@:] curryB ( a:, a:,<4) curryB (3;a:) 2 
Volume is :24 for length 3 width 2 and height 4 


If you look back to the returned function, it includes 3 : conjunctions to 
separate monad and dyad calls.  I don't understand how multiple : works, and if 
you look closely, only the dyadic sides appear to be complete expressions that 
curry both the 4 and the 3 

actually upon closer inspection of parentheses matching, at the top level, only 
the middle : exists.  On a monadic call the left of that would be executed, but 
within that left side, only the right side of : provides the "right" answer.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to