Jsoftware
High-Performance Development Platform

Extra empty item from an empty table

View: New views
10 Messages — Rating Filter:   Alert me  

Extra empty item from an empty table

by Don Guinn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Was doing some recursive directory searches and needed to combine the
results from multiple directories but when a directory did not find any
items I got an item of nulls. Looking at the example shown below, I don't
think I should get the item of nulls.

   (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
+---+----+
|abc|de  |
+---+----+
|fg |h   |
+---+----+
|ww |xxxx|
+---+----+
|ww |xxxx|
+---+----+
   (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
+---+----+
|abc|de  |
+---+----+
|fg |h   |
+---+----+
|ww |xxxx|
+---+----+
   (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
+---+--+
|abc|de|
+---+--+
|fg |h |
+---+--+
|   |  |
+---+--+

Why is there a third item which is empty in the last case? Am I
misunderstanding something about append?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: Extra empty item from an empty table

by Fraser Jackson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The following may be a simpler example of your problem.

   (2 2$;:'abc de fg h'),0$1 2 $a:
┌───┬──┐
│abc│de│
├───┼──┤
│fg │h │
└───┴──┘
   (2 2$;:'abc de fg h'),0 2$a:
┌───┬──┐
│abc│de│
├───┼──┤
│fg │h │
└───┴──┘
   (2 2$;:'abc de fg h'),0$a:
┌───┬──┐
│abc│de│
├───┼──┤
│fg │h │
├───┼──┤
│   │  │
└───┴──┘


----- Original Message -----
From: "Don Guinn" <donguinn@...>
To: "Programming forum" <programming@...>
Sent: Sunday, June 29, 2008 9:20 AM
Subject: [Jprogramming] Extra empty item from an empty table


> Was doing some recursive directory searches and needed to combine the
> results from multiple directories but when a directory did not find any
> items I got an item of nulls. Looking at the example shown below, I don't
> think I should get the item of nulls.
>
>   (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
> +---+----+
> |abc|de  |
> +---+----+
> |fg |h   |
> +---+----+
> |ww |xxxx|
> +---+----+
> |ww |xxxx|
> +---+----+
>   (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
> +---+----+
> |abc|de  |
> +---+----+
> |fg |h   |
> +---+----+
> |ww |xxxx|
> +---+----+
>   (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
> +---+--+
> |abc|de|
> +---+--+
> |fg |h |
> +---+--+
> |   |  |
> +---+--+
>
> Why is there a third item which is empty in the last case? Am I
> misunderstanding something about append?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm 

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

Re: Extra empty item from an empty table

by Don Guinn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for your comments. After reading the dictionary on Raze (;)
several times I see why it didn't work. However, after fooling around some
more I found what did work as I wanted. Need to spend a little time really
understanding it.

   ;(<2 2$;:'abc de fg h'),<1#,:;:'ww xxxx'
+---+----+
|abc|de  |
+---+----+
|fg |h   |
+---+----+
|ww |xxxx|
+---+----+
   ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
+---+--+
|abc|de|
+---+--+
|fg |h |
+---+--+


 On Sat, Jun 28, 2008 at 4:37 PM, Fraser Jackson <fraser.jackson@...>
wrote:

>
> The following may be a simpler example of your problem.
>
>  (2 2$;:'abc de fg h'),0$1 2 $a:
> ┌───┬──┐
> │abc│de│
> ├───┼──┤
> │fg │h │
> └───┴──┘
>  (2 2$;:'abc de fg h'),0 2$a:
> ┌───┬──┐
> │abc│de│
> ├───┼──┤
> │fg │h │
> └───┴──┘
>  (2 2$;:'abc de fg h'),0$a:
> ┌───┬──┐
> │abc│de│
> ├───┼──┤
> │fg │h │
> ├───┼──┤
> │   │  │
> └───┴──┘
>
>
> ----- Original Message ----- From: "Don Guinn" <donguinn@...>
> To: "Programming forum" <programming@...>
> Sent: Sunday, June 29, 2008 9:20 AM
> Subject: [Jprogramming] Extra empty item from an empty table
>
>
>> Was doing some recursive directory searches and needed to combine the
>> results from multiple directories but when a directory did not find any
>> items I got an item of nulls. Looking at the example shown below, I don't
>> think I should get the item of nulls.
>>
>>  (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
>> +---+----+
>> |abc|de  |
>> +---+----+
>> |fg |h   |
>> +---+----+
>> |ww |xxxx|
>> +---+----+
>> |ww |xxxx|
>> +---+----+
>>  (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
>> +---+----+
>> |abc|de  |
>> +---+----+
>> |fg |h   |
>> +---+----+
>> |ww |xxxx|
>> +---+----+
>>  (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
>> +---+--+
>> |abc|de|
>> +---+--+
>> |fg |h |
>> +---+--+
>> |   |  |
>> +---+--+
>>
>> Why is there a third item which is empty in the last case? Am I
>> misunderstanding something about append?
>> ----------------------------------------------------------------------
>> 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

RE: Extra empty item from an empty table

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The problem is that you have a box containing structure
(rank-2 arrays).  When you raze them, you keep some of that structure.
But when you have 0 of the boxes, you lose the internal structure;
the boxed empty is always treated like the contents are 0$0 .

;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'

is equivalent to

(2 2$;:'abc de fg h'),0#,:;:'ww xxxx'


Note the subtle difference in boxing between this and your first failing case.

Henry Rich


> -----Original Message-----
> From: programming-bounces@...
> [mailto:programming-bounces@...] On Behalf Of Don Guinn
> Sent: Saturday, June 28, 2008 9:46 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Extra empty item from an empty table
>
> Thank you for your comments. After reading the dictionary on Raze (;)
> several times I see why it didn't work. However, after
> fooling around some
> more I found what did work as I wanted. Need to spend a
> little time really
> understanding it.
>
>    ;(<2 2$;:'abc de fg h'),<1#,:;:'ww xxxx'
> +---+----+
> |abc|de  |
> +---+----+
> |fg |h   |
> +---+----+
> |ww |xxxx|
> +---+----+
>    ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
> +---+--+
> |abc|de|
> +---+--+
> |fg |h |
> +---+--+
>
>
>  On Sat, Jun 28, 2008 at 4:37 PM, Fraser Jackson
> <fraser.jackson@...>
> wrote:
> >
> > The following may be a simpler example of your problem.
> >
> >  (2 2$;:'abc de fg h'),0$1 2 $a:
> > ----T--┐
> > │abc│de│
> > +---+--+
> > │fg │h │
> > L---+---
> >  (2 2$;:'abc de fg h'),0 2$a:
> > ----T--┐
> > │abc│de│
> > +---+--+
> > │fg │h │
> > L---+---
> >  (2 2$;:'abc de fg h'),0$a:
> > ----T--┐
> > │abc│de│
> > +---+--+
> > │fg │h │
> > +---+--+
> > │   │  │
> > L---+---
> >
> >
> > ----- Original Message ----- From: "Don Guinn" <donguinn@...>
> > To: "Programming forum" <programming@...>
> > Sent: Sunday, June 29, 2008 9:20 AM
> > Subject: [Jprogramming] Extra empty item from an empty table
> >
> >
> >> Was doing some recursive directory searches and needed to
> combine the
> >> results from multiple directories but when a directory did
> not find any
> >> items I got an item of nulls. Looking at the example shown
> below, I don't
> >> think I should get the item of nulls.
> >>
> >>  (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
> >> +---+----+
> >> |abc|de  |
> >> +---+----+
> >> |fg |h   |
> >> +---+----+
> >> |ww |xxxx|
> >> +---+----+
> >> |ww |xxxx|
> >> +---+----+
> >>  (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
> >> +---+----+
> >> |abc|de  |
> >> +---+----+
> >> |fg |h   |
> >> +---+----+
> >> |ww |xxxx|
> >> +---+----+
> >>  (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
> >> +---+--+
> >> |abc|de|
> >> +---+--+
> >> |fg |h |
> >> +---+--+
> >> |   |  |
> >> +---+--+
> >>
> >> Why is there a third item which is empty in the last case? Am I
> >> misunderstanding something about append?
> >>
> ----------------------------------------------------------------------
> >> 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

Re: Extra empty item from an empty table

by Don Guinn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What trapped me was that I used

   $0#i.1 2
0 2

quite a lot and it keeps structure. But raze does not.  Thanks.

2008/6/28 Henry Rich <HenryHRich@...>:

> The problem is that you have a box containing structure
> (rank-2 arrays).  When you raze them, you keep some of that structure.
> But when you have 0 of the boxes, you lose the internal structure;
> the boxed empty is always treated like the contents are 0$0 .
>
> ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
>
> is equivalent to
>
> (2 2$;:'abc de fg h'),0#,:;:'ww xxxx'
>
>
> Note the subtle difference in boxing between this and your first failing
> case.
>
> Henry Rich
>
>
> > -----Original Message-----
> > From: programming-bounces@...
> > [mailto:programming-bounces@...] On Behalf Of Don Guinn
> > Sent: Saturday, June 28, 2008 9:46 PM
> > To: Programming forum
> > Subject: Re: [Jprogramming] Extra empty item from an empty table
> >
> > Thank you for your comments. After reading the dictionary on Raze (;)
> > several times I see why it didn't work. However, after
> > fooling around some
> > more I found what did work as I wanted. Need to spend a
> > little time really
> > understanding it.
> >
> >    ;(<2 2$;:'abc de fg h'),<1#,:;:'ww xxxx'
> > +---+----+
> > |abc|de  |
> > +---+----+
> > |fg |h   |
> > +---+----+
> > |ww |xxxx|
> > +---+----+
> >    ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
> > +---+--+
> > |abc|de|
> > +---+--+
> > |fg |h |
> > +---+--+
> >
> >
> >  On Sat, Jun 28, 2008 at 4:37 PM, Fraser Jackson
> > <fraser.jackson@...>
> > wrote:
> > >
> > > The following may be a simpler example of your problem.
> > >
> > >  (2 2$;:'abc de fg h'),0$1 2 $a:
> > > ----T--┐
> > > │abc│de│
> > > +---+--+
> > > │fg │h │
> > > L---+---
> > >  (2 2$;:'abc de fg h'),0 2$a:
> > > ----T--┐
> > > │abc│de│
> > > +---+--+
> > > │fg │h │
> > > L---+---
> > >  (2 2$;:'abc de fg h'),0$a:
> > > ----T--┐
> > > │abc│de│
> > > +---+--+
> > > │fg │h │
> > > +---+--+
> > > │   │  │
> > > L---+---
>  > >
> > >
> > > ----- Original Message ----- From: "Don Guinn" <donguinn@...>
> > > To: "Programming forum" <programming@...>
> > > Sent: Sunday, June 29, 2008 9:20 AM
> > > Subject: [Jprogramming] Extra empty item from an empty table
> > >
> > >
> > >> Was doing some recursive directory searches and needed to
> > combine the
> > >> results from multiple directories but when a directory did
> > not find any
> > >> items I got an item of nulls. Looking at the example shown
> > below, I don't
> > >> think I should get the item of nulls.
> > >>
> > >>  (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
> > >> +---+----+
> > >> |abc|de  |
> > >> +---+----+
> > >> |fg |h   |
> > >> +---+----+
> > >> |ww |xxxx|
> > >> +---+----+
> > >> |ww |xxxx|
> > >> +---+----+
> > >>  (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
> > >> +---+----+
> > >> |abc|de  |
> > >> +---+----+
> > >> |fg |h   |
> > >> +---+----+
> > >> |ww |xxxx|
> > >> +---+----+
> > >>  (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
> > >> +---+--+
> > >> |abc|de|
> > >> +---+--+
> > >> |fg |h |
> > >> +---+--+
> > >> |   |  |
> > >> +---+--+
> > >>
> > >> Why is there a third item which is empty in the last case? Am I
> > >> misunderstanding something about append?
> > >>
> > ----------------------------------------------------------------------
> > >> 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

Re: Extra empty item from an empty table

by neitzel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Don Guinn wrote:
>   (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
>   (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
>   (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
>Why is there a third item which is empty in the last case? Am I
>misunderstanding something about append?

Take a look at the shapes of your three right sides, i.e.
        ;2#<,:;:'ww xxxx'
        ;1#<,:;:'ww xxxx'
        ;0#<,:;:'ww xxxx'

and compare this with the (much simpler) right sides
        2 # ,: ;: 'ww xxxx'
        1 # ,: ;: 'ww xxxx'
        0 # ,: ;: 'ww xxxx'

which all append nicely.

Returning to your original problem:  I consider the design of
1!:0 to be botched.  I'd prefer it to return an empty 0 6 matrix
in the case of non-matches.  Also, it should work on the
root directory as it does on any other directory.  I always
have to code around these special cases.  (The standard
'dir' wrapper doesn't extend nicely to empty matches, either.)

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

RE: Extra empty item from an empty table

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's not raze that loses the structure.  raze makes a
list of items: all structure in the ITEMS is preserved.

The problem is that when a list of boxes goes empty, the
structure inside the boxes is lost.

When you have

< 2 5 $ 6

the box contains a table.  If you have a list of such boxes,
each holds a table.  If you use ; on such a boxed list, the
structure of the contents will be revealed.

But when you have a 0-length array of such things, they are
no longer (a list of 0) boxes containing tables, but
(a list of 0) boxes containing empty lists.

You could imagine having empty lists contain structure, but
apparently APL variants tried that and the results were bad.

The bottom line: when you have boxes containing tables, you must
treat the empty-list-of-boxes as a special case.

Henry Rich

> -----Original Message-----
> From: programming-bounces@...
> [mailto:programming-bounces@...] On Behalf Of Don Guinn
> Sent: Saturday, June 28, 2008 11:16 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Extra empty item from an empty table
>
> What trapped me was that I used
>
>    $0#i.1 2
> 0 2
>
> quite a lot and it keeps structure. But raze does not.  Thanks.
>
> 2008/6/28 Henry Rich <HenryHRich@...>:
>
> > The problem is that you have a box containing structure
> > (rank-2 arrays).  When you raze them, you keep some of that
> structure.
> > But when you have 0 of the boxes, you lose the internal structure;
> > the boxed empty is always treated like the contents are 0$0 .
> >
> > ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
> >
> > is equivalent to
> >
> > (2 2$;:'abc de fg h'),0#,:;:'ww xxxx'
> >
> >
> > Note the subtle difference in boxing between this and your
> first failing
> > case.
> >
> > Henry Rich
> >
> >
> > > -----Original Message-----
> > > From: programming-bounces@...
> > > [mailto:programming-bounces@...] On Behalf Of Don Guinn
> > > Sent: Saturday, June 28, 2008 9:46 PM
> > > To: Programming forum
> > > Subject: Re: [Jprogramming] Extra empty item from an empty table
> > >
> > > Thank you for your comments. After reading the dictionary
> on Raze (;)
> > > several times I see why it didn't work. However, after
> > > fooling around some
> > > more I found what did work as I wanted. Need to spend a
> > > little time really
> > > understanding it.
> > >
> > >    ;(<2 2$;:'abc de fg h'),<1#,:;:'ww xxxx'
> > > +---+----+
> > > |abc|de  |
> > > +---+----+
> > > |fg |h   |
> > > +---+----+
> > > |ww |xxxx|
> > > +---+----+
> > >    ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
> > > +---+--+
> > > |abc|de|
> > > +---+--+
> > > |fg |h |
> > > +---+--+
> > >
> > >
> > >  On Sat, Jun 28, 2008 at 4:37 PM, Fraser Jackson
> > > <fraser.jackson@...>
> > > wrote:
> > > >
> > > > The following may be a simpler example of your problem.
> > > >
> > > >  (2 2$;:'abc de fg h'),0$1 2 $a:
> > > > ----T--┐
> > > > │abc│de│
> > > > +---+--+
> > > > │fg │h │
> > > > L---+---
> > > >  (2 2$;:'abc de fg h'),0 2$a:
> > > > ----T--┐
> > > > │abc│de│
> > > > +---+--+
> > > > │fg │h │
> > > > L---+---
> > > >  (2 2$;:'abc de fg h'),0$a:
> > > > ----T--┐
> > > > │abc│de│
> > > > +---+--+
> > > > │fg │h │
> > > > +---+--+
> > > > │   │  │
> > > > L---+---
> >  > >
> > > >
> > > > ----- Original Message ----- From: "Don Guinn"
> <donguinn@...>
> > > > To: "Programming forum" <programming@...>
> > > > Sent: Sunday, June 29, 2008 9:20 AM
> > > > Subject: [Jprogramming] Extra empty item from an empty table
> > > >
> > > >
> > > >> Was doing some recursive directory searches and needed to
> > > combine the
> > > >> results from multiple directories but when a directory did
> > > not find any
> > > >> items I got an item of nulls. Looking at the example shown
> > > below, I don't
> > > >> think I should get the item of nulls.
> > > >>
> > > >>  (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
> > > >> +---+----+
> > > >> |abc|de  |
> > > >> +---+----+
> > > >> |fg |h   |
> > > >> +---+----+
> > > >> |ww |xxxx|
> > > >> +---+----+
> > > >> |ww |xxxx|
> > > >> +---+----+
> > > >>  (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
> > > >> +---+----+
> > > >> |abc|de  |
> > > >> +---+----+
> > > >> |fg |h   |
> > > >> +---+----+
> > > >> |ww |xxxx|
> > > >> +---+----+
> > > >>  (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
> > > >> +---+--+
> > > >> |abc|de|
> > > >> +---+--+
> > > >> |fg |h |
> > > >> +---+--+
> > > >> |   |  |
> > > >> +---+--+
> > > >>
> > > >> Why is there a third item which is empty in the last case? Am I
> > > >> misunderstanding something about append?
> > > >>
> > >
> ----------------------------------------------------------------------
> > > >> 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

Re: Extra empty item from an empty table

by Fraser Jackson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I do not think Don's original problem had anything to do with ; but with the
append.  The raze only contributes because it can change the rank of the
object appended.

Following the Dictionary in a different case

   (i.2 4) , i.0
0 1 2 3
4 5 6 7
0 0 0 0

Adding what looks like something that is empty, adds an item to the array.
Append first constructs an item by moving to rank 1,It then pads using fill
elements to the shape of the items of the left argument.  Note the
difference with

    (i.2 4) , i. 0 2
0 1 2 3
4 5 6 7

For a rank 3 array we get

   (i. 2 3 4) , i. 0 2
 0  1  2  3
 4  5  6  7
 8  9 10 11

12 13 14 15
16 17 18 19
20 21 22 23

 0  0  0  0
 0  0  0  0
 0  0  0  0

   (i.2 3 4),i. 0 0 0
 0  1  2  3
 4  5  6  7
 8  9 10 11

12 13 14 15
16 17 18 19
20 21 22 23

Don's final question in his first post was the correct question.  The effect
of appending an empty array depends on the shape of both the arguments.
----- Original Message -----
From: "Henry Rich" <HenryHRich@...>
To: "'Programming forum'" <programming@...>
Sent: Sunday, June 29, 2008 5:49 PM
Subject: RE: [Jprogramming] Extra empty item from an empty table


It's not raze that loses the structure.  raze makes a
list of items: all structure in the ITEMS is preserved.

The problem is that when a list of boxes goes empty, the
structure inside the boxes is lost.

When you have

< 2 5 $ 6

the box contains a table.  If you have a list of such boxes,
each holds a table.  If you use ; on such a boxed list, the
structure of the contents will be revealed.

But when you have a 0-length array of such things, they are
no longer (a list of 0) boxes containing tables, but
(a list of 0) boxes containing empty lists.

You could imagine having empty lists contain structure, but
apparently APL variants tried that and the results were bad.

The bottom line: when you have boxes containing tables, you must
treat the empty-list-of-boxes as a special case.

Henry Rich

> -----Original Message-----
> From: programming-bounces@...
> [mailto:programming-bounces@...] On Behalf Of Don Guinn
> Sent: Saturday, June 28, 2008 11:16 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Extra empty item from an empty table
>
> What trapped me was that I used
>
>    $0#i.1 2
> 0 2
>
> quite a lot and it keeps structure. But raze does not.  Thanks.
>
> 2008/6/28 Henry Rich <HenryHRich@...>:
>
> > The problem is that you have a box containing structure
> > (rank-2 arrays).  When you raze them, you keep some of that
> structure.
> > But when you have 0 of the boxes, you lose the internal structure;
> > the boxed empty is always treated like the contents are 0$0 .
> >
> > ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
> >
> > is equivalent to
> >
> > (2 2$;:'abc de fg h'),0#,:;:'ww xxxx'
> >
> >
> > Note the subtle difference in boxing between this and your
> first failing
> > case.
> >
> > Henry Rich
> >
> >
> > > -----Original Message-----
> > > From: programming-bounces@...
> > > [mailto:programming-bounces@...] On Behalf Of Don Guinn
> > > Sent: Saturday, June 28, 2008 9:46 PM
> > > To: Programming forum
> > > Subject: Re: [Jprogramming] Extra empty item from an empty table
> > >
> > > Thank you for your comments. After reading the dictionary
> on Raze (;)
> > > several times I see why it didn't work. However, after
> > > fooling around some
> > > more I found what did work as I wanted. Need to spend a
> > > little time really
> > > understanding it.
> > >
> > >    ;(<2 2$;:'abc de fg h'),<1#,:;:'ww xxxx'
> > > +---+----+
> > > |abc|de  |
> > > +---+----+
> > > |fg |h   |
> > > +---+----+
> > > |ww |xxxx|
> > > +---+----+
> > >    ;(<2 2$;:'abc de fg h'),<0#,:;:'ww xxxx'
> > > +---+--+
> > > |abc|de|
> > > +---+--+
> > > |fg |h |
> > > +---+--+
> > >
> > >
> > >  On Sat, Jun 28, 2008 at 4:37 PM, Fraser Jackson
> > > <fraser.jackson@...>
> > > wrote:
> > > >
> > > > The following may be a simpler example of your problem.
> > > >
> > > >  (2 2$;:'abc de fg h'),0$1 2 $a:
> > > > ----T--┐
> > > > │abc│de│
> > > > +---+--+
> > > > │fg │h │
> > > > L---+---
> > > >  (2 2$;:'abc de fg h'),0 2$a:
> > > > ----T--┐
> > > > │abc│de│
> > > > +---+--+
> > > > │fg │h │
> > > > L---+---
> > > >  (2 2$;:'abc de fg h'),0$a:
> > > > ----T--┐
> > > > │abc│de│
> > > > +---+--+
> > > > │fg │h │
> > > > +---+--+
> > > > │   │  │
> > > > L---+---
> >  > >
> > > >
> > > > ----- Original Message ----- From: "Don Guinn"
> <donguinn@...>
> > > > To: "Programming forum" <programming@...>
> > > > Sent: Sunday, June 29, 2008 9:20 AM
> > > > Subject: [Jprogramming] Extra empty item from an empty table
> > > >
> > > >
> > > >> Was doing some recursive directory searches and needed to
> > > combine the
> > > >> results from multiple directories but when a directory did
> > > not find any
> > > >> items I got an item of nulls. Looking at the example shown
> > > below, I don't
> > > >> think I should get the item of nulls.
> > > >>
> > > >>  (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
> > > >> +---+----+
> > > >> |abc|de  |
> > > >> +---+----+
> > > >> |fg |h   |
> > > >> +---+----+
> > > >> |ww |xxxx|
> > > >> +---+----+
> > > >> |ww |xxxx|
> > > >> +---+----+
> > > >>  (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
> > > >> +---+----+
> > > >> |abc|de  |
> > > >> +---+----+
> > > >> |fg |h   |
> > > >> +---+----+
> > > >> |ww |xxxx|
> > > >> +---+----+
> > > >>  (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
> > > >> +---+--+
> > > >> |abc|de|
> > > >> +---+--+
> > > >> |fg |h |
> > > >> +---+--+
> > > >> |   |  |
> > > >> +---+--+
> > > >>
> > > >> Why is there a third item which is empty in the last case? Am I
> > > >> misunderstanding something about append?
> > > >>
> > >
> ----------------------------------------------------------------------
> > > >> 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 

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

RE: Extra empty item from an empty table

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 6.02, no-match does return shape 0 5:

   $ 1!:0 '\bin\kdfslgjskd'
0 5

For concatenating such lists I use

endtoend =: 1 : ';@:(<@u)'

   1!:0"0 endtoend 'C:\J\bin\*.dll';'C:\J\bin\*.ijs';'C:\J\bin\*.nonexist'
+---------------------+------------------+-------+---+------+
|j.dll                |2008 3 4 10 0 36  |1642496|rw-|-----a|
+---------------------+------------------+-------+---+------+
|jnative.dll          |2008 2 23 11 30 42|53248  |rw-|-----a|
+---------------------+------------------+-------+---+------+
|profile.ijs          |2008 2 9 18 34 40 |1219   |rw-|-----a|
+---------------------+------------------+-------+---+------+
|profilex.ijs         |2008 2 2 17 33 25 |783    |rw-|-----a|
+---------------------+------------------+-------+---+------+
|profilex_template.ijs|2008 2 9 18 41 0  |882    |rw-|-----a|
+---------------------+------------------+-------+---+------+

Henry Rich

> -----Original Message-----
> From: programming-bounces@...
> [mailto:programming-bounces@...] On Behalf Of
> neitzel@...
> Sent: Saturday, June 28, 2008 11:55 PM
> To: programming@...
> Subject: Re: [Jprogramming] Extra empty item from an empty table
>
> Don Guinn wrote:
> >   (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
> >   (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
> >   (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
> >Why is there a third item which is empty in the last case? Am I
> >misunderstanding something about append?
>
> Take a look at the shapes of your three right sides, i.e.
> ;2#<,:;:'ww xxxx'
> ;1#<,:;:'ww xxxx'
> ;0#<,:;:'ww xxxx'
>
> and compare this with the (much simpler) right sides
> 2 # ,: ;: 'ww xxxx'
> 1 # ,: ;: 'ww xxxx'
> 0 # ,: ;: 'ww xxxx'
>
> which all append nicely.
>
> Returning to your original problem:  I consider the design of
> 1!:0 to be botched.  I'd prefer it to return an empty 0 6 matrix
> in the case of non-matches.  Also, it should work on the
> root directory as it does on any other directory.  I always
> have to code around these special cases.  (The standard
> 'dir' wrapper doesn't extend nicely to empty matches, either.)
>
> Martin
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm

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

Re: Extra empty item from an empty table

by bill lam-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In J5.04 no-match also return shape 0 5,

But beware, 1!:0 for linux returns 6 columns not 5, eg,
    1!:0 '/tmp'
+---+------------------+-----+---+------+----------+
|tmp|2008 6 30 11 41 22|12288|rwx|----d-|drwxrwxrwt|
+---+------------------+-----+---+------+----------+

Henry Rich wrote:

> On 6.02, no-match does return shape 0 5:
>
>    $ 1!:0 '\bin\kdfslgjskd'
> 0 5
>
> For concatenating such lists I use
>
> endtoend =: 1 : ';@:(<@u)'
>
>    1!:0"0 endtoend 'C:\J\bin\*.dll';'C:\J\bin\*.ijs';'C:\J\bin\*.nonexist'
> +---------------------+------------------+-------+---+------+
> |j.dll                |2008 3 4 10 0 36  |1642496|rw-|-----a|
> +---------------------+------------------+-------+---+------+
> |jnative.dll          |2008 2 23 11 30 42|53248  |rw-|-----a|
> +---------------------+------------------+-------+---+------+
> |profile.ijs          |2008 2 9 18 34 40 |1219   |rw-|-----a|
> +---------------------+------------------+-------+---+------+
> |profilex.ijs         |2008 2 2 17 33 25 |783    |rw-|-----a|
> +---------------------+------------------+-------+---+------+
> |profilex_template.ijs|2008 2 9 18 41 0  |882    |rw-|-----a|
> +---------------------+------------------+-------+---+------+
>
> Henry Rich
>
>> -----Original Message-----
>> From: programming-bounces@...
>> [mailto:programming-bounces@...] On Behalf Of
>> neitzel@...
>> Sent: Saturday, June 28, 2008 11:55 PM
>> To: programming@...
>> Subject: Re: [Jprogramming] Extra empty item from an empty table
>>
>> Don Guinn wrote:
>>>   (2 2$;:'abc de fg h'),;2#<,:;:'ww xxxx'
>>>   (2 2$;:'abc de fg h'),;1#<,:;:'ww xxxx'
>>>   (2 2$;:'abc de fg h'),;0#<,:;:'ww xxxx'
>>> Why is there a third item which is empty in the last case? Am I
>>> misunderstanding something about append?
>> Take a look at the shapes of your three right sides, i.e.
>> ;2#<,:;:'ww xxxx'
>> ;1#<,:;:'ww xxxx'
>> ;0#<,:;:'ww xxxx'
>>
>> and compare this with the (much simpler) right sides
>> 2 # ,: ;: 'ww xxxx'
>> 1 # ,: ;: 'ww xxxx'
>> 0 # ,: ;: 'ww xxxx'
>>
>> which all append nicely.
>>
>> Returning to your original problem:  I consider the design of
>> 1!:0 to be botched.  I'd prefer it to return an empty 0 6 matrix
>> in the case of non-matches.  Also, it should work on the
>> root directory as it does on any other directory.  I always
>> have to code around these special cases.  (The standard
>> 'dir' wrapper doesn't extend nicely to empty matches, either.)
>>
>> Martin
>> ----------------------------------------------------------------------
>> 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
LightInTheBox - Buy quality products at wholesale price!