This is a proposed change only to dyad and $ , is that right?

What problem does this solve?

Henry Rich

On 8/18/2020 6:18 PM, David Lambert wrote:
Proposal to allow a single infinity in the shape.  This model doesn't
consider empty arrays or other issues I'm unaware of.  If infinity is in
the shape, the product of the defined ranks must be a factor of the tally
of y .

reshape=: dyad define
  shape=. x
  if. _ -.@e. shape do.
   shape $ y
   return.
  end.
  error=. 13!:8
  valueError=. 21
  vector=. , y  NB. or <"_1 followed by unboxing
  if. 1 < +/ _ = shape do.
   'at most one replacement' error valueError
  end.
  f=. (# vector) % (*/ shape -. _)
  if. (~: <.) f do.  NB. f must be integral
   'shape mismatch' error valueError
  end.
  shape =. f (shape i. _)} shape
  shape $ vector
)
    _ 4 reshape i. 6
|shape mismatch: error
|   'shape mismatch'    error 21

    _ _ 2 reshape 'abcd'
|at most one replacement: error
|   'at most one replacement'    error 21

    2 _ reshape i. 6
0 1 2
3 4 5

    _ 2 reshape i. 6     NB.    _2 [\ i. 6
0 1
2 3
4 5

    _ 2 $ i.6
|domain error
|   _ 2    $i.6

    NB. while we're at it, permit negative shape values akin to integers
(i.).
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


--
This email has been checked for viruses by AVG.
https://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to