Neither of these notations allows you to write a zero- or one-element list.
(I know, you can't directly write a zero- or one-element vector either*.)
You can get around that by changing the notation to "{a;b;c}". But this
still seems inelegant.
>[Sharp APL has] new primitives called enclose and disclose. The result of
>enclose is always a scalar. Disclose is a left inverse of enclose.
I find this one easiest to understand. Enclose always returns a scalar of
(new) type "tree"; arrays are still homogeneous but the scalars in a tree
array may disclose to any object; the "standard scalar" of type tree (the
filler value for overtake or expand, corresponding to numeric zero and
character blank) is the enclosure of an empty tree. This is the "grounded"
tree model.
There's also a "floating" tree model, whose main distinction is that for any
scalar foo, foo equals enclose foo. (In the grounded model, "0" "<0" "<<0"
(monadic "<" is enclose) are all distinct objects, and ">0" gives a domain
error.) I think this causes unnecessary complications -- you have to allow
true heterogeneous arrays, and I think the "first" element is distinguished.
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
*I lied. '' denotes a zero-element character vector. What you can't write
is a numeric vector of length zero or one, or a character vector of length
one, as a constant. Or any array of higher rank. Are 2D lists permitted in
GCOS APL or APL2? Does "2 2 rho {a;b;c;d}" work?
Answer:
(1) No.
(2) I dunno. Does anybody else ?
Uh, but what exactly is the "empty tree"? If we define
<scalar> ::= <number> | <character> | enclose(<array>)
<array> ::= n-dimensional array of (<scalar>)'s, n >= 0
then there IS no empty tree --- every enclosure has an array inside it. If
you want a "default" scalar of type tree, I think you'd be better off
reintroducing ONE object x0 satisfying x0 = >x0, and letting that be the
default value. (Is this perhaps what you meant?)
--
David Moews mo...@h-sc4.harvard.EDU ...!seismo!harvard!h-sc4
By "empty tree" I meant "zero-length vector of type tree." The "standard
tree scalar" is ENCLOSE 0 RHO ENCLOSE anything. Sorry about the confusion.