Quote:

>In the recent thread on bridge hand one-liners, I posted a one-liner that

>included the idiom "B {replicate} {each} {enclose} V" where B is a vector

>of bit n-vectors and V is a simple n-vector.

>In old APLs the first function would have been called "compress" rather

>than "replicate," and would have been denoted by '/'.

>In modern mainframe APL*Plus, '/' is called "replicate" (a compatible

>extension to compress) and works in the idiom.

>In APL2, '/' is also called "replicate," but is implemented differently.

>The familiar idiom gives a domain error.

>In APL+ (formerly APL*Plus II and III), '/' is implemented using the APL2

>definition, but the mainframe-compatible definition is available as

>{quad}REPL. The idiom fails using '/', but works using {quad}REPL.

>What's the preferred way of coding this behavior in APL2?

I usually use:

{del}z{is}B REPL V

[1]z{is}B/V{del}

Then B REPL{each}{enclose}V works for nested B and single V.

If B is single and V is nested, then

B/{each}V

works without the cover function.

The idea is that, for single B, B/ is a function derived from numeric B and

operator '/'. That won't work for nested B (in APL2 and APLIII), so you need

to define a cover function to be {each}ed.

This circumlocution is not neccessary in Dyalog APL.

You might also define a more general operator, along the lines of

{del}z{is}B(N REP)X

[1]z{is}B/[N]X{del}

for replication along any axis. (Another example of the anomalies of [...])

Quote:

>--

>"Sacred cows make the tastiest hamburger." -- Abbie Hoffman