Replicate in APL2 
Author Message
 Replicate in APL2

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?

--

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



Fri, 09 Oct 1998 03:00:00 GMT  
 Replicate in APL2

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




Sat, 10 Oct 1998 03:00:00 GMT  
 Replicate in APL2
Preferred?  I dunno.  Workable ...

     {del}  z{is}r replicate a
          z{is}r/a
     {del}

which covers "/" making a function from the operator.

Now      v Replicate {each} w    works just fine.

But you knew this ...

--



Sun, 11 Oct 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. self-replicating-code, self-replicating-messages

2. APL2/2 to APL2/W95/NT

3. Best way to replicate a string?

4. Replicate Question

5. How to replicate two or more file-systems?

6. Replicating inheritance critique

7. Replicated inheritance revisited.

8. Replicated constants and frozen features

9. self-replicating code

10. Self replicating code

11. Replicating program

12. Loading/Replicating value into MMX register

 

 
Powered by phpBB® Forum Software