Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!csrd.uiuc.edu!sp27.csrd.uiuc.edu!jaxon From: jaxon@sp27.csrd.uiuc.edu (Greg P. Jaxon) Newsgroups: comp.lang.apl Subject: Re: Do I really need a loop? Message-ID: <1991May15.145054.18276@csrd.uiuc.edu> Date: 15 May 91 14:50:54 GMT References: <3970004@hpwrce.HP.COM> <15160016@hpdmd48.boi.hp.com> Sender: news@csrd.uiuc.edu (news) Organization: UIUC Center for Supercomputing Research and Development Lines: 29 rrr@hpdmd48.boi.hp.com (Rudi Rynders) writes (I paraphase): >I'd like to 1 2 3 x 7 and get 7 14 21 > 4 5 6 8 32 40 48 >Instead of writing a loop to do this, does APL have a more concise way? We used to call this "Middle Product". In 1973 APL/700's dyadic scalar primitives let you name one axis along which the 'replication' would occur. By default it replicated along the last axis, so MxV would get your answer. APL2 and APLB use the same syntax (axis brackets after the 'x') to name the (one or more) axes in the higher rank argument where the axes of the lower rank argument can be found. (Length 2 vectors are found along the first axis of a 2x3 matrix.) So in these languages you'd say M x[#IO] V. APLB (I'm not sure about APL2) also does a Middle Product operation without axis brackets, it tries to match the trailing axes of its arguments, so transpose V x transpose M would also work, at higher cost. The axis specification only affects the top level of nesting when 'x' is applied as a pervasive function to a pair of nested arrays. To affect deeper levels of the nest, APLB applied this definition of axis bracket, and this default defn to the Each operator. So you'd give bracket specifiers for each level of the nest, and apply them to the primitive and n-1 levels of Each. Needless to say, these are not ISO standard definitions, and axis brackets are considered clumsy in the new streamlined syntax of J. Regards, Greg Jaxon