u=. -
   k=. 2
   y=. i.3 4

   (u/y) ; (u/k{.y) u (u/k}.y)
+-------+---------------+
|4 5 6 7|_12 _13 _14 _15|
+-------+---------------+

so the two expressions are not equivalent.


R.E. Boss



> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens david alis
> Verzonden: zaterdag 22 september 2007 8:34
> Aan: Programming forum
> Onderwerp: [Jprogramming] vocabulary question concerning / (insert) -
> revisited
> 
> Concerning the behaviour of insert / when the argument has one item.
> 
> e.g.
> 
>    u/  i.1 4
> 
> Henry Rich wrote on Sept 8th:
> 
> http://www.jsoftware.com/pipermail/programming/2007-September/008052.html
> 
> > If y has only one item, the result of u/ y is that item, for any u.
> > It makes sense as
> > (Item -#y) u ... u (Item _2) u (Item _1)
> > where if there is no item _2, the sequence ends with item _1.
> 
> But this does not follow from the Vocabulary entry:
> http://www.jsoftware.com/help/dictionary/d420.htm
> =====================================================
> If y has no items (that is, 0=#y), the result of u/y is the neutral or
> identity element of the function u .
> A neutral of a function u is a value e such that x u e ↔ x or e u x ↔ x,
> for every x in the domain (or some significant sub-domain such as boolean)
> of u .
> 
> This definition of insertion over an argument having zero items extends
> partitioning identities of the form u/y ↔ (u/k{.y) u (u/k}.y) to the
cases
> k
> e. 0,#y .
> =====================================================
> 
> In other words, when k = 1 then
> 
> u/y ↔ (u/1{.y) u (u/1}.y)
> 
> But this is not what happens now:
> 
> u =. 0:
> y =. i. 1 4
> 
> u/y
> 0 1 2 3
> 
>    (u/1{.y) u (u/1}.y)  NB.
> |domain error
> |   (u/1{.y)u(    u/1}.y)
> 
> And that is what should happen.
> The 'domain error' occurs because the function 0: does not
> have an identity element.
> 
> Based on this, the current behaviour of / is wrong.
> 
> The current behaviour also leads to some pretty nasty program faults.
> For example, if the domain of u is numeric but its range is character,
> then
> the current implementation u/ returns a numeric result for
> a 1-item array - after which nastiness may be expected.
> Furthermore, because in the 1-item argument case, u isn't invoked
> no protection is possible against such nastiness.

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

Reply via email to