static char Sccsid
[] = "ab.c @(#)ab.c 1.1 10/1/82 Berkeley ";
/* While TANSTAAFL, in APL there is a close approximation. It
* is possible to perform a "take" of more elements than an
* array actually contains (to be padded with zeros or blanks).
* If "td1()" detects that a dimension exceeds what the array
* actually contains it will return 1. Special code is then
* required to force the extra elements in the new array to
* zero or blank. This code is supposed to work for null items
for(i
=0; i
<idx
.rank
; i
++) {
fill
[i
] = idx
.dim
[i
] - k
;
for(i
=0; i
<idx
.rank
; i
++) {
struct item
*q
, *nq
, *s2vect();
int r
; /* set to 1 if take > array dim */
r
= !q
->size
; /* Weird stuff for null items */
if (q
->rank
== 0){ /* Extend scalars */
nq
= newdat(q
->type
, p
->size
, 1);
if(p
->rank
> 1 || q
->rank
!= p
->size
)
for(i
=0; i
<p
->size
; i
++) {
/* If an attempt is made to drop more than what
* exists, modify the drop to drop exactly what
register struct item
*p
, *q
;
if(p
->rank
> 1 || p
->size
!= q
->rank
)
idx
.idx
[i
] = fix(getdat(p
)) - thread
.iorg
;
idx
.idx
[i
] = p
->rank
-1-i
;
for(i
=0; i
<idx
.rank
; i
++)
for(i
=0; i
<idx
.rank
; i
++) {
for(i
=0; i
<idx
.rank
; i
++) {
k
= topfix() - thread
.iorg
;
if(k
< 0 || k
>= idx
.rank
)
o
= idx
.del
[k
] * (idx
.dim
[k
]-1);
idx
.del
[k
] = -idx
.del
[k
];
for(i
=0; i
<idx
.rank
; i
++)
p
= newdat(idx
.type
, idx
.rank
, n
);
copy(IN
, idx
.dim
, p
->dim
, idx
.rank
);
putdat(sp
[-1], getdat(p
));
/* Zero appropriate elements of an array created by taking
* more than you originally had. I apologize for the "dirty"
* argument passing (passing a pointer to an integer array
* through "forloop()" which treats it as an integer) and for
* the general dumbness of this code.
for(i
=0; i
<idx
.rank
; i
++)
if (fill
[i
] > 0 && idx
.idx
[i
] >= fill
[i
]
|| fill
[i
] < 0 && idx
.idx
[i
] < -fill
[i
]){
putdat(p
, (p
->type
==DA
) ? zero
: (data
)' ');