Dear Blake,
If the purpose of the ,'' needs documenting, add a comment to the
code and/or assign ,'' to a variable, say
PRESERVE_EMBEDDED_SCALARS
and use the variable where needed. And I personally would have been
disappointed if
gg←,'' 'a' 'b'
⍴gg
Dear Fred,
Some additional comments -- after some thought, it seems to me that the
APL2 designers wanted to make nested arrays do more than just encapsulate
arbitrary arrays. My box/unbox do that well. APL allows operations over
an ARRAY of data rather than piece by piece. That is the APL philo
Dear Fred,
While your code does help in one area, it has a problem in another, i.e.:
gg←,'' 'a' 'b'
⍴gg
3
Your code says there are three but to the programmer there are only two.
The '' is just there to make the rest work. I suppose you can just
remember that and change your indexes
Blake,
Since box and unbox are implemented directly in terms of enclose and
disclose, I have to believe that the latter can handle the parameters
you require and in a less verbose fashion.
Consider the following code:
gg ← ,'' 'a' 'b'
gg
┌→─┐
│┌⊖┐ ab│
││ │ │
│└─
Dear Fred,
Thanks for taking the time and effort to provide your feedback. I looked
at your example.
I gave my example in simple terms in the hopes that the full extent of the
idea would be understood. In my explanation of the problem, I should have
made it clear that the key can be any charact
Hello Blake,
After having asked you to present a use case where the behavior of
box/unbox differs from enclose/disclose and you graciously replied, I
felt obligated to spend a little time studying the issue. I did that
and have come to the conclusion that both boxed and nested arrays are
I tried the ravel everything method, but that lead to APL2 disclosing a
vector into a matrix APL2 fought me touth and nail. I gave up and
wrote box/unbox.
--blake
On Sat, May 17, 2014 at 11:18 PM, Frederick H. Pitts wrote:
> Blake,
>
> Thanks for the detailed response. I unders
That bring be back to my previous argument that the APL designers made a
mistake when they defined 'a' to be a character instead of a single-element
array. It's inconsistent, and leads to ugly code where all
single-character-strings have to be escaped as such: (,'a'), or as you put
it: (1⍴'a') whic
Blake,
Thanks for the detailed response. I understand the issue more clearly
now.
I think I would ask the user to reshape scalar arguments to vectors
(e.g. (1⍴'k')(1⍴'v')). But then, that is as onerous as having to
remember to use box everywhere its required.
Regards,
Fred
On
Lastly,
⍴(box 'abc'),box 'def'
┌→┐
│2│
└─┘
Blake
Oh, and I should point out this too:
⍴(box 'k'),box 'v'
┌→┐
│2│
└─┘
⍴'kv'
┌→┐
│2│
└─┘
Blake
On Sat, May 17, 2014 at 9:59 PM, Blake McBride wrote:
> Greetings,
>
> I suppose my examples were meant to show that my box and unbox function as
> I hoped, and that they functioned consi
Greetings,
I suppose my examples were meant to show that my box and unbox function as
I hoped, and that they functioned consistently with all data
configurations. I wasn't intending to point out the benefits. I suppose I
thought that might be clear from my earlier emails. In response to you,
ho
Hello Blake,
Please present at least one use case where box/unbox behavior differs
from ⊂/⊃ behavior. For all the use cases you present in your email, I
do not believe there is a difference.
Regards,
Fred Pitts
Retired Chemical Engineer
On Tue, 2014-05-13 at 09:00 -0500, Blake McBride
That fixed it for me. Thanks!
On Wed, May 14, 2014 at 1:14 PM, Juergen Sauermann <
juergen.sauerm...@t-online.de> wrote:
> Hi Jay,
>
> thanks, fixed in SVN 267.
>
> /// Jürgen
>
>
>
> On 05/14/2014 05:44 PM, Jay Foad wrote:
>
>> That's because of a bug in GNU APL:
>>
>>x←(1 2)(3 4)
>>
Hi Jay,
thanks, fixed in SVN 267.
/// Jürgen
On 05/14/2014 05:44 PM, Jay Foad wrote:
That's because of a bug in GNU APL:
x←(1 2)(3 4)
(a b)←x
a≡1 2
0
:-(
Jay.
On 14 May 2014 15:24, Blake McBride wrote:
Your unbox doesn't work. The following does:
(s r)←⊃x ⋄ z←(⊃s)
That's because of a bug in GNU APL:
x←(1 2)(3 4)
(a b)←x
a≡1 2
0
:-(
Jay.
On 14 May 2014 15:24, Blake McBride wrote:
> Your unbox doesn't work. The following does:
>
> (s r)←⊃x ⋄ z←(⊃s)⍴⊃r
>
>
> On Wed, May 14, 2014 at 3:43 AM, Jay Foad wrote:
>>
>> On 13 May 2014 15:00, Bl
Your unbox doesn't work. The following does:
(s r)←⊃x ⋄ z←(⊃s)⍴⊃r
On Wed, May 14, 2014 at 3:43 AM, Jay Foad wrote:
> On 13 May 2014 15:00, Blake McBride wrote:
> > Here are the functions, examples to follow:
> >
> > ∇box[⎕]∇
> > [0] z←box x
> > [1] z←⊂(⊂⍴x),⊂,x
> >
> > ∇unbox[⎕]∇
Thanks!
On Wed, May 14, 2014 at 3:43 AM, Jay Foad wrote:
> On 13 May 2014 15:00, Blake McBride wrote:
> > Here are the functions, examples to follow:
> >
> > ∇box[⎕]∇
> > [0] z←box x
> > [1] z←⊂(⊂⍴x),⊂,x
> >
> > ∇unbox[⎕]∇
> > [0] z←unbox x
> > [1] z←(⊃x[⎕IO])⍴⊃(x←⊃x)[⎕IO+1]
>
> FY
On 13 May 2014 15:00, Blake McBride wrote:
> Here are the functions, examples to follow:
>
> ∇box[⎕]∇
> [0] z←box x
> [1] z←⊂(⊂⍴x),⊂,x
>
> ∇unbox[⎕]∇
> [0] z←unbox x
> [1] z←(⊃x[⎕IO])⍴⊃(x←⊃x)[⎕IO+1]
FYI you can write your box as: z←⊂(⍴x)(,x)
and unbox as: (s r)←⊃x ⋄ z←s⍴r
Jay.
I wrote two APL functions that operate like ⊃ and ⊂ packing an APL1 array
into a scalar and unpacking it back into its APL1 array. It works as
Iverson preferred, and is simple to understand and use. There are no
exceptions to what can be nested (i.e. scalars can be recursively nested).
And there
20 matches
Mail list logo