On 17 August 2011 15:53, Rudi Mann <[email protected]> wrote: > Why is a scalar left argument sufficient in this case > (10&#.^:_1) 123 > 1 2 3 > but when I omit the power adverb and use the inverse function directly > I need a vector to get the same result? > 10#:123 > 3 > 10 10 10#:123 > 1 2 3 > Isn't #:^:_1 the same as #. since they are inverse functions?
#. and #: are not exactly inverse. With #., if you use an atomic left argument, say 10, it is replicated to fit the size (shape, actually) of the right argument. So 10 #. 1 2 3 is the same as 10 10 10 #. 1 2 3 , and ultimately +/ 100 10 1 * 1 2 3 (see http://www.jsoftware.com/help/dictionary/d401.htm). There is no similar rule in the definition of #: . Note that x #: 123 is different: since 123 is not a vector, if x is a single number, how would you know to what size to replicate it? The size could be computed as base-x number of digits of y, i.e. >.x^.>:y , but reshaping x is probably not a good idea anyway. Here is one reason why: >.1^.>: 123 _ while 1 #: 123 0 (no reshaping) makes a perfectly good sense. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
