a. The fact that a primitive can be readily defined
in terms of others is not a strong reason for
excluding it. The dyad - (equivalent to (+ -)"0)
is an example of this.
b. Whatever the merits of the new facility, nearly
all the merits would still be present if it is
assigned a new symbol, without disrupting anything.
c. Control structures can not be satisfactorily replaced by tacit constructs.
For example:
z=. z0
for_i. i.n do.
a0=. read i
a1=. i{boo
a2=. i{coo
z=. z f1 a0 f2 a1 f3 a2
end.
The blocks within a control structure can refer
to too many names than can coexist felicitously
in a tacit construct.
d. The difference in performance between the
following two constructs
for_e. g do. c=. (<./i) (i=. {&c^:_ >e)}c end.
c=. (({~^:_ )~ ([:<./{)`[`]} ])&.>/ (|.g),<c
is not due to control structures versus tacit
but rather that the former uses amend-in-place
whereas the latter does not. Consider:
f0=: > @ ({&.>/) @ (] , <@[)
f1=: 4 : 0
z=. x
for_e. |.y do. z=. (>e){z end.
)
y=: 10 ?&.> 5e4$10
x (f0 -: f1) y
1
ts 'x f0 y'
0.0617705 468416
ts 'x f1 y'
0.196699 265536
In other words, even if ds were primitive, the
performance on
c (({~^:_)~ ([:<./{)`[`]} ])&.> ds g
would be similar to
c=. (({~^:_ )~ ([:<./{)`[`]} ])&.>/ (|.g),<c
rather than to
for_e. g do. c=. (<./i) (i=. {&c^:_ >e)}c end.
----- Original Message -----
From: "R.E. Boss" <[EMAIL PROTECTED]>
Date: Thursday, September 14, 2006 6:53 am
Subject: [Jgeneral] Redefining dyadic /
> There are good reasons to redefine the dyadic adverb / called
> "table" in the
> vocabulary, and one reason not to do so.
>
> 0) One of the aims of an array programming language should be
> to make
> explicit loops (for, while) superfluous. Or at least avoidable at
> no cost.
>
> 1) The current definition of u/ is only a shorthand for
> u"(lu,_)
>
> 2) It is preferable that monadic and dyadic use of primitives
> match as
> much as possible
>
> 3) There exists a good candidate for dyadic /
>
> _1) Incompatibility
>
> Some remarks
>
> 1) There are cases in which explicit loops are unavoidable
> if good
> performance is important.
>
> Even(?) Hui used a for-loop in a recent verb
> http://www.jsoftware.com/pipermail/programming/2006-
> September/003258.html
>
> If I replace in his verb comp the line
>
> for_e. g do. c=. (<./i) (i=. {&c^:_ >e)}c end.
>
> with the equivalent
>
> c=. (({~^:_ )~ ([:<./{)`[`]} ])&.>/ (|.g),<c
>
> to obtain verb comp1, than I get (for e=: edgs~ 5e4) a far worse
> performance
> ts 'comp e'
> 0.45996326 7448832
>
> ts 'comp1 e'
> 2.6279606 7448896
>
> (comp -: comp1) e
> 1
>
> 2) More primitives are shorthand for complicated expressions,
> e.g. /.
> is equivalent to 1 : '[EMAIL PROTECTED] ='
>
> See http://www.jsoftware.com/jwiki/PrimitivePrimitives for other
> examples.
> But u"(lu,_) is not complicated (enough) for a shorthand.
>
> What's more, the title (table) does not even reflect its outcome.
>
> Try 1 2 3 ;/ 4 5 6 7 as one of the problems I encountered when my
> J learning
> curve was a quite bit steeper than today. Of course 1 2 3 ;"0/ 4
> 5 6 7
> gives the desired outcome, but if you know that, than you also can
> come up
> with the equivalent 1 2 3 ;"0"0 _ [ 4 5 6 7
>
> 3) There are many examples, < and > belonging to the best, where
> monadic and dyadic use have nothing in common. But if they do, it
> is at
> least of mnemonic use.
>
> 4) The good candidate I am proposing is just the 'for'-loop
> Hui used.
>
> So I would like to have
>
> x u/ y
>
> to be defined by " apply u/ on the concatenation of x and y"
>
> or, more formally, equivalent to
>
> ds=: 1 : 0 NB. dyadic scan
> :
> for_j. |.x do. y=. j u y end.
> )
>
> Then performance can be further improved by special coding ...!
>
> _1) No remarks on incompatibility.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm