Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

"Problem" with disclose
On both APL+Win and APL2, why does

{disclose}'A' 'B' '' 'D' 'E'

return  5 0{rho}''   ?

I would, of course, much prefer that it return  5 1{rho}'AB DE'

In other words, if the argument to disclose consists of a mixture of
scalars and empty vectors, disclose appears to "throw away" the
non-empty data.

At the company where I work, all the APLers use disclose as an idiom
to mean "remove one level of nesting from a nested vector, padding the
shorter items in the resulting array to be as long as the longest
item."  Our code is full of such uses of disclose, and it shocked me
to see this "edge condition."  I suppose there's some mathematical
reason why it works the way it does, but I don't find it very useful,
and it's causing us problems.

Report this thread to moderator Post Follow-up to this message
Old Post
RAV
01-06-05 01:55 PM


Re: "Problem" with disclose
On Thu, 30 Dec 2004 14:59:15 -0500, "David Liebtag"
<DavidLiebtag@vermontel.net> wrote:

>The first sentence of APL2 Programming: Language Reference Manual's
>discussion of disclose is:
>
>"All items of R must be scalars and/or arrays of the same rank."
>
>Clearly, this is not the case for your example.
>
>The LRM does go on to discuss the case where the items of the right argumen
t
>have different shapes (on page 95).  It states:
>
>If items of R are scalar or have different shapes, each is padded to a shap
e
>that represents the greatest length along each axis of all items of R; that
>is, the shape of each item is padded to
>
>    {first}{max}/(,{rho}{each}R)~{enclose}{iota}0
>
>For your case, this results in each item being padded to zero length.
>
>Perhaps you would find the results more useful if you said this:
>
>    {disclose}, {each} R
>
>David Liebtag
>IBM APL Products and Services
>

Thanks for your response, but they ARE scalars and arrays of the same
rank (1).  If they weren't, you would get a RANK ERROR, which you do
get, for example, if you try  {disclose}(,0) (1 1{rho}0).  Only
scalars are scalar-extended.

I can see, though, why the maximum "length" in this case is 0, since
the length of the empty vector(s) is 0, and scalars have no "length."
True mathematically, but not nice in this case.

And while ,{each} would be fine if the argument to {disclose} could be
counted on to ALWAYS be a nested array containing items of rank 1 or
less, it can't.  If, for example, a simple matrix is passed directly
to {disclose}, the result is the same simple matrix.  Performing
,{each} beforehand would lead to a differently shaped result.  I'm
afraid that a generalized solution is going to be more complicated
than that.

Report this thread to moderator Post Follow-up to this message
Old Post
RAV
01-06-05 08:57 PM


Re: "Problem" with disclose
In message <r6p8t010f1kulqefqjei6nu9olc57s2lbp@4ax.com>, RAV
<PaulR@Case.com> writes
>
>I can see, though, why the maximum "length" in this case is 0, since
>the length of the empty vector(s) is 0, and scalars have no "length."
>True mathematically, but not nice in this case.

How else are you going to define scalar extension?


--
John Sullivan

Report this thread to moderator Post Follow-up to this message
Old Post
John Sullivan
01-06-05 08:57 PM


Re: "Problem" with disclose
RAV wrote:
> On both APL+Win and APL2, why does
>
>       {disclose}'A' 'B' '' 'D' 'E'
>
> return  5 0{rho}''   ?
>

www.jsoftware.com

a=:'A' 'B' '' 'D' 'E'
|syntax error
|   a=:    'A''B''''D''E'

NB. this above does not work because space is not an operation

a=:'A';'B';'';'D';'E'
a
+-+-++-+-+
|A|B||D|E|
+-+-++-+-+
$a
5
>a
A
B

D
E
$>a
5 1
|:>a
AB DE
$|:>a
1 5


Report this thread to moderator Post Follow-up to this message
Old Post
gosi
01-06-05 08:57 PM


Re: "Problem" with disclose
The ultimate root cause of the "problematic" behaviour reported by RAV lies
in decisions of many years ago.

Trenchard Moore, a theoretician at IBM, proposed two possible ways of
handling generalised arrays.  James Brown et al at IBM chose one path when
developing APL2 whereas Ken Iverson selected the other when extending Sharp
APL and developing J. Ultimately the selection between these possibilities
should be decided by utility - which choice gives a language that is more
useful and can be extended to consistently encompass new features.

I digress, but an easy distinction between these two routes (both equally
logical) is whether it is possible to enclose a scalar.  In APL2 a scalar
cannot be enclosed whereas for SAPL and J it can.

As David Leibtag has pointed out, the linking of 4 scalars and one empty
vector into a single object cause the scalars to collapse to zero length
vectors because the scalars cannot be enclosed. It is necessary, therefore,
to change their rank beforehand. With SAPL and J the supposed "problem"
cannot occur and the result of the disclose would be a matrix of 5 rows and
one column.

Martin

"RAV" <PaulR@Case.com> wrote in message
 news:jqd8t0t5urd33vhc3jmnj31ogq8ns9j4f2@
4ax.com...
> On both APL+Win and APL2, why does
>
>      {disclose}'A' 'B' '' 'D' 'E'
>
> return  5 0{rho}''   ?
>
> I would, of course, much prefer that it return  5 1{rho}'AB DE'
>
> In other words, if the argument to disclose consists of a mixture of
> scalars and empty vectors, disclose appears to "throw away" the
> non-empty data.
>
> At the company where I work, all the APLers use disclose as an idiom
> to mean "remove one level of nesting from a nested vector, padding the
> shorter items in the resulting array to be as long as the longest
> item."  Our code is full of such uses of disclose, and it shocked me
> to see this "edge condition."  I suppose there's some mathematical
> reason why it works the way it does, but I don't find it very useful,
> and it's causing us problems.



Report this thread to moderator Post Follow-up to this message
Old Post
Martin Turner
01-07-05 08:55 AM


Re: "Problem" with disclose
I have been referring to this news group. What in particular do you want
to call my attention to?

/Todd

LatLong wrote:
> I would refer you to this new group thread.
>
> "Todd Marshall" <Todd@WithGLEE.com> wrote in message
> news:T9mBd.9768$iC4.5250@newssvr30.news.prodigy.com...
> 
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Todd Marshall
01-09-05 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

APL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:43 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.