... apologies for indulging in minutia. However, often doing this with J reveals hidden clarity. I do like to understand edge cases.
the context is a bug I found in my code when an empty set turns up (rare). Up until that point I hadn't tried that out. Although the unit test may appear non nonsensical, the actual case involved boxed contents. It's idiomatic to what I was solving. I really did want in this instance, to ignore empty sets. The fill behaviour lead to an incorrect result for me. The good news is that as a result of this thread, the J treatment appears logical to me now. My discovery path went something like this... I was doing a lot of thinking in terms of simple vectors. Later, I was doing an append to a shape of rank 2. I made an incorrect assumption based on the simple vector work I had done moments before which was still fresh in my mind. In other projects / languages probably something like this would fragment off into several variations. In J, it didn't. What still eludes me still is how you'd come to a language design decision like this, and remain firm on it. Wow is all. Thanks for commenting. I'm going to read this thread in more detail again shortly. Comment: I'm not from an APL background... but I did think there were some strong resemblances to J in the link that Dan posted. That must be a mile stone for me. On 11 January 2013 23:32, Roger Hui <rogerhui.can...@gmail.com> wrote: > And what is the point of your example please? > > If you append an m-item table to an n-item one the resultant table has m+n > items. That works when m or n or both are 0. No surprise here. > > In the original example a list is appended to a table. The list is treated > as a one-row table. > > > > On Fri, Jan 11, 2013 at 2:39 PM, Graham Parkhouse < > graham.parkho...@ntlworld.com> wrote: > > > (0 2$0),i.2 2 > > 0 1 > > 2 3 > > > > On Fri, 11 Jan 2013 09:00:42 -0800 > > Roger Hui <rogerhui.can...@gmail.com> wrote: > > > > > It is not a bug and the following sequence illustrates why the behavior > > > is > > > reasonable: > > > > > > (n$0) , i. 2 2 [ n=: 3 > > > 0 0 0 > > > 0 1 0 > > > 2 3 0 > > > (n$0) , i. 2 2 [ n=: 2 > > > 0 0 > > > 0 1 > > > 2 3 > > > (n$0) , i. 2 2 [ n=: 1 > > > 0 0 > > > 0 1 > > > 2 3 > > > (n$0) , i. 2 2 [ n=: 0 > > > 0 0 > > > 0 1 > > > 2 3 > > > > > > > > > > > > On Fri, Jan 11, 2013 at 8:52 AM, Steven Taylor <tayl...@gmail.com> > > > wrote: > > > > > > > I didn't expect this extra (0 0) in the result. > > > > > > > > (0 $ 0),i. 2 2 > > > > 0 0 > > > > 0 1 > > > > 2 3 > > > > > > > > i.e. nothing prepended to shape equals the same shape (not more or > > > less) > > > > > > > > Is this a bug, or does this make sense in some situations? What > > > should the > > > > J way be? > > > > > > > > For a simple list, we get my expected behaviour : > > > > > > > > (0 $ 0),i. 3 > > > > 0 1 2 > > > > > > > > Here's a possible solution > > > > > > > > empty=:(<'') = [: < [ > > > > > > > > empty 0 $ 0 > > > > NB. build result > > > > (xci sort~ u,xa),ya > > > > ) > > > > > > > > empty=:(<'') = [: < [ > > > > > > > > carefulappend=:13 : '(empty x)}. x,y' f. > > > > > > > > carefulappend2=:4 : 0 > > > > if. (empty x) do. > > > > r=.y > > > > elseif. empty y do. > > > > r=.x > > > > elseif. do. > > > > r=.x,y > > > > end. > > > > r > > > > ) > > > > > > > > (0 $ 0) carefulappend i. 2 2 > > > > 0 1 > > > > 2 3 > > > > > > > > (0 $ 0) carefulappend2 i. 2 2 > > > > 0 1 > > > > 2 3 > > > > > > > > thanks, > > > > -Steven > > > > --------------------------------------------------------------------- > > > - > > > > For information about J forums see > > > http://www.jsoftware.com/forums.htm > > > > > > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm