My first silly ? on character lists and ]display
5 posts
• Page 1 of 1
My first silly ? on character lists and ]display
Hi,
I'm brand new to apl but have programmed a bit in other languages.
I typed in this:
vh←('z' '1')('cb' 'cb')('c' 'c')
My intention was to have a list composed of some number of sub lists, each sublist was to have 2 members of some amount of characters -- think maybe, given name and family name instead of the silly little characters i have here.
When i issued ]display vh
I expected to see something along the lines of the following:
Instead, i saw something totally unexpected:
Why would the second element be a list of individual items while the first and third seem to have been concatenated into a single element? I could almost accept it if the second was displayed as cbcb in just a single box. But i am totally confused. I spent a lot of time searching the documentation, but couldn't see a reason why my data was stored as such. So if you have the means to enlighten me (maybe just a page in the manual to point to) i am willing and waiting.
Thanks for your help.
I'm brand new to apl but have programmed a bit in other languages.
I typed in this:
vh←('z' '1')('cb' 'cb')('c' 'c')
My intention was to have a list composed of some number of sub lists, each sublist was to have 2 members of some amount of characters -- think maybe, given name and family name instead of the silly little characters i have here.
When i issued ]display vh
I expected to see something along the lines of the following:
- Code: Select all
┌→────────────────────┐
│ ┌→──┐ ┌→────┐ ┌→──┐ │
│ │z 1│ │cb cb│ │c c│ │
│ └∊──┘ └∊────┘ └∊──┘ │
└∊────────────────────┘
Instead, i saw something totally unexpected:
- Code: Select all
┌→────────────────────────┐
│ ┌→─┐ ┌→──────────┐ ┌→─┐ │
│ │z1│ │ ┌→─┐ ┌→─┐ │ │cc│ │
│ └──┘ │ │cb│ │cb│ │ └──┘ │
│ │ └──┘ └──┘ │ │
│ └∊──────────┘ │
└∊────────────────────────┘
Why would the second element be a list of individual items while the first and third seem to have been concatenated into a single element? I could almost accept it if the second was displayed as cbcb in just a single box. But i am totally confused. I spent a lot of time searching the documentation, but couldn't see a reason why my data was stored as such. So if you have the means to enlighten me (maybe just a page in the manual to point to) i am willing and waiting.
Thanks for your help.
- StewKing
- Posts: 4
- Joined: Sun Jun 12, 2011 11:17 pm
Re: My first silly ? on character lists and ]display
Because the enclose of a simple scalar is the same simple scalar...
'a'≡⊂'a'
1
Which encapsulates the fundamental difference between the "enclosing" of APL2/NARS-based APLs and the "boxing" of Sharp/J (where "box" always puts a box around the argument). Sometimes known as "floating" versus "grounded" - although I forget which is which.
There's a rather elegant expression of Phil Benkard's which captures this - and hopefully someone will be along sooner than I can lay my hands on the reference.
There once were proposals for APL2 to offer both options (because they are both useful for different reasons), but I don't think anything ever came of it.
'a'≡⊂'a'
1
Which encapsulates the fundamental difference between the "enclosing" of APL2/NARS-based APLs and the "boxing" of Sharp/J (where "box" always puts a box around the argument). Sometimes known as "floating" versus "grounded" - although I forget which is which.
There's a rather elegant expression of Phil Benkard's which captures this - and hopefully someone will be along sooner than I can lay my hands on the reference.
There once were proposals for APL2 to offer both options (because they are both useful for different reasons), but I don't think anything ever came of it.
Visit http://apl.dickbowman.com to read more from Dick Bowman
-
Dick Bowman - Posts: 235
- Joined: Thu Jun 18, 2009 4:55 pm
Re: My first silly ? on character lists and ]display
Hi Stew,
On input, 'abc' is a shorthand for: ('a' 'b' 'c'). On output, both are displayed as just: abc.
An analogous experiment with numbers may be less surprising. Substituting 9 1 3 2 for 'z' '1' 'c' 'b', respectively (and so (3 2) for 'cb'):
John.
On input, 'abc' is a shorthand for: ('a' 'b' 'c'). On output, both are displayed as just: abc.
'abc'
abc
'a' 'b' 'c'
abc
('a' 'b' 'c') ≡ 'abc'
1
An analogous experiment with numbers may be less surprising. Substituting 9 1 3 2 for 'z' '1' 'c' 'b', respectively (and so (3 2) for 'cb'):
]display (9 1) ((3 2)(3 2)) (3 3)
┌→────────────────────────────┐
│ ┌→──┐ ┌→────────────┐ ┌→──┐ │
│ │9 1│ │ ┌→──┐ ┌→──┐ │ │3 3│ │
│ └~──┘ │ │3 2│ │3 2│ │ └~──┘ │
│ │ └~──┘ └~──┘ │ │
│ └∊────────────┘ │
└∊────────────────────────────┘
John.
- JohnS|Dyalog
Re: My first silly ? on character lists and ]display
From the APL Bookshelf of Fun, here's Benkard's definition of enclose...
⊂⍵ ←→ 1⌷⍵ ⍵
Two papers which contain discussion (there are more)...
Nested Arrays and Operators - Some Issues In Depth; APL92 Conference Proceedings; ACM; ISBN 0-89791-477-5
Making Nested Arrays Work For You; APL95 Conference Proceedings Companion
The latter may be harder to locate.
As John much more helpfully points out, things are often clearer with numbers.
Incidentally, I'll put in a plug for ]displayr as a more informative alternative to ]display (they're both in the dfns workspace, not sure whether ]displayr is available as a user command right out of the box - if not then EEfR).
⊂⍵ ←→ 1⌷⍵ ⍵
Two papers which contain discussion (there are more)...
Nested Arrays and Operators - Some Issues In Depth; APL92 Conference Proceedings; ACM; ISBN 0-89791-477-5
Making Nested Arrays Work For You; APL95 Conference Proceedings Companion
The latter may be harder to locate.
As John much more helpfully points out, things are often clearer with numbers.
Incidentally, I'll put in a plug for ]displayr as a more informative alternative to ]display (they're both in the dfns workspace, not sure whether ]displayr is available as a user command right out of the box - if not then EEfR).
Visit http://apl.dickbowman.com to read more from Dick Bowman
-
Dick Bowman - Posts: 235
- Joined: Thu Jun 18, 2009 4:55 pm
Re: My first silly ? on character lists and ]display
Ok, the numbers thing helped a lot. The 'ab' being shorthand for 'a' 'b' is a bit counterintuitive, but i'll get used to it. I'm sure there much more to come as i try to do something useful. To everyone who supplied answers and other places to look, it'll keep me busy and off the streets, thanks!
-stew
-stew
- StewKing
- Posts: 4
- Joined: Sun Jun 12, 2011 11:17 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group