Re: [Jforum] Some suggestions about J desing

86 views
Skip to first unread message
Message has been deleted

Henry Rich

unread,
Jul 16, 2025, 8:29:24 AM7/16/25
to fo...@jsoftware.com
That loses all the monadic verbs: a high price.

Henry Rich

On 7/16/2025 8:15 AM, rodolfo sigmados mas wrote:
Hello, I think that the monic + operator applied to any rank could be just the sum, so that + should be +/ @: ;   and the old definitition could be obtained by +"0 so applying the operator at rank 0 allow you to obtain the old (previous) meaning.  The same argument should be applied to <. , >, -, etc.  This could allow for a more concise expIression, for example arithmetic mean is just + % #, the statistical range is just >. - <.  ,for someone learning J that is clearer (in my humble opinion).

  The product of elements of an array should be * a,  that is *a should be */ ; a  ,
 you could for example apply +"1 to get an array with the sum of the 1 cells.
  
  The old meaning signus could be obtained with *"0  (rank 0 application).

  I am sure that there might be some downsides to this proposal, but I think that it globally could make J a little terser and easier to learn.
To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Message has been deleted

Raul Miller

unread,
Jul 16, 2025, 5:57:29 PM7/16/25
to fo...@jsoftware.com, Henry Rich
That's still a high price.

For example:

-5 7
_5 _7
-/5 7
_2

--
Raul

On Wed, Jul 16, 2025 at 9:04 AM rodolfo sigmados mas <rsig...@gmail.com> wrote:
>
> It only affect those verbs that have a meanful reduction sum, sustraction, product, min, max, or and and, and perhaps other that could take advantage. For example shape $ a don't change because reducing here is not an operation with little meaning.
>
> Thanks anyway for expressing your opinion and for being the latest main developer of J.

rodolfo sigmados mas

unread,
Jul 16, 2025, 7:29:03 PM7/16/25
to forum, Raul Miller, Henry Rich
Yes, that is a high price, and there is a reason this operator is different than the other: the minus operator is not commutative and not  associative unlike the others.  The initial idea was  considering an array as an object, not just individuals parts.  what should be the meaning of unary minus in this context?,   it should be one that makes this true:    0:  -: (+ + -) . So there is a certain philosophical idea of considering unary operators as messages send to objects (arrays) and defining minus like that is natural.   So the alternate sum should use -/ , in this case this  use the dyadic minus.    So this is a little modification of the initial proposal defining monadic minus as 0: - + 

Raul Miller

unread,
Jul 17, 2025, 12:03:31 AM7/17/25
to rodolfo sigmados mas, forum, Henry Rich
There's a variety of other examples which would introduce conflicts
with the original spec you proposed. I'll let you think about them.

But I would also like to call out another issue. Monadic + in j is
complex conjugate:

+3j4 _7j_9
3j_4 _7j9

--
Raul

rodolfo sigmados mas

unread,
Jul 17, 2025, 3:37:39 AM7/17/25
to forum, Raul Miller, forum, Henry Rich, rodolfo sigmados mas
Yes, of course I know that monadic + is conjugate, prior to changing a monadic verb it is supposed I should now what that verbs do.  That is why I said that using rank 0 maintain the old behaviour, so +"0  should be old monadic +, that is conjugate.  The same way that %"0 should be inverse, but % array should be (actual J)   1 % +/  array, that is the inverse of the product, to satisfy with the new suggested behaviour that 1: -:  * * % 
 
  There may be other examples which would introduce conflicts, perhaps you can suggest some of them to spark my imagination how to overcome it.    Your suggestion about monadic minus not following the -/ rule was a clue to realize that inverse operator should obey the law of being inverse (in math there is the concept of symmetrical element respect to an operation so if you define a rule for one operator the symmetrical operator should obey the law to conserve the symmetry property, that is way I propose that % array is just a real number  the inverse of the product of the elements of the array, the same way that minus is the opposite of the sum of the elements of the array of shape n,  new + => current   +/ @: , 

 It seems conversation can spark new ideas.

Igor Zhuravlov

unread,
Jul 17, 2025, 5:29:34 AM7/17/25
to fo...@jsoftware.com
On 7/16/2025 10:15 PM, rodolfo sigmados mas wrote:
> Hello, I think that the monic + operator applied to any rank could be just
> the sum, so that + should be +/ @: ; and the old definitition could be
> obtained by +"0 so applying the operator at rank 0 allow you to obtain the
> old (previous) meaning. [...]
>
> I am sure that there might be some downsides to this proposal, but I
> think that it globally could make J a little terser and easier to learn.

It's interesting idea, but:

Proposal - Current J - Savings
u u/ -1 symbol
u"0 u +2 symbols

Your proposal could make J more terser if u/ form is used at least twice as
often as u in current J code base.

--
Regards,
Igor


Raul Miller

unread,
Jul 17, 2025, 5:43:55 PM7/17/25
to rodolfo sigmados mas, forum, Henry Rich
Meanwhile, J's plus is rank zero by definition.

Anyways, it sounds not so much like you are specifying changes to J,
but instead it sounds like you are specifying some internal interfaces
that would work behind the scenes in your implementation.

And that's fine, presuming you are happy with the implementation, when
you get there. (That said, I'm not sure how well your system would
perform. But I guess finding that out is half of the fun.)

Thanks,

--
Raul

rodolfo sigmados mas

unread,
Jul 17, 2025, 6:52:41 PM7/17/25
to forum, Igor Zhuravlov
Your accounting is not perfectly accurate because sometimes you don't need to use the rank zero trick, for example in common cases like  the inverse you can use  1 % x, for the opposite use 0 - x so that is just one more character but sometimes you need two characters. Sorry if this is a just accounting  nitpicking.

rodolfo sigmados mas

unread,
Jul 17, 2025, 7:03:22 PM7/17/25
to forum, Raul Miller, forum, Henry Rich, rodolfo sigmados mas

Since I am thinking in developing a J flavor in Common Lisp, perhaps I can change some rules because mostly is a hobby project.   I havte a lot of code done with LLMs but there are many bugs and I am finding that working by myself the code is much better, shorter and easy to read, but I can do hundred lines of code in seconds like the LLMs. Perhaps the ability of using arrays with element type of any kind, hash tables, macros and other tools can make an useful addition to J to experiment.  

 Here is a simple example of how to define monadic operators, at the end there is a macro that makes the work much easier.

(defun f-tally(a)
  (cond ((arrayp a) (first (array-dimensions a)))
 ((listp a) (length a))
 (t 1)))

(defun array-flatten(a)
  (make-array (array-total-size a) :displaced-to a))

(defun f-signum(a)
  (cond ((numberp a) (signum a))
((listp a) (mapcar #'signum a))
((arrayp a) (make-array (array-dimensions a) :displaced-to
(map 'vector #'signum (array-flatten a))))))
(defun f-square(a)
  (cond ((numberp a) (* a a))
((listp a) (mapcar (lambda(x) (* x x)) a))
((arrayp a) (make-array (array-dimensions a) :displaced-to
(map 'vector (lambda(x)(* x x)) (array-flatten a))))))


(defun f-reciprocal(a)
  (labels ((reciproco (x)
      (if (zerop x) 0 (/ 1 x))))
    (cond ((numberp a) (reciproco a))
  ((listp a) (mapcar #'reciproco a))
  ((arrayp a) (make-array (array-dimensions a) :displaced-to
  (map 'vector #'reciproco (array-flatten a)))))))
;;; (if (eql (type-of a) 'ratio) (/ 1 a) (/ 1.0 a))

(defmacro j-defun(name verb)
  `(defun ,name(a)
  (cond ((numberp a) (,verb a))
((listp a) (mapcar #',verb a))
((arrayp a) (make-array (array-dimensions a) :displaced-to
(map 'vector #',verb (array-flatten a)))))))
;;; define sqrt with the name raiz-cuadrada  using the macro   (j-defun j-raiz-cuadrada sqrt)

Raul Miller

unread,
Jul 18, 2025, 3:36:17 AM7/18/25
to fo...@jsoftware.com, Igor Zhuravlov
This is not a trick:

+ b. 0
0 0 0

Note also that +"_ or +/@, are [formally speaking] definitions which
*contain* the + verb.

--
Raul
Reply all
Reply to author
Forward
0 new messages