50g System RPL list processing
|
10-28-2014, 02:12 PM
Post: #5
|
|||
|
|||
RE: 50g System RPL list processing
(06-21-2014 02:13 AM)ttw Wrote: A list sum should return zero on an empty (or non-existent) list or the only element if a single element list (or a single variable is returned.)I agree with your view. This is one of the improvements that were implemented in newRPL, and it makes things much more consistent. And it doesn't break compatibility, because if you have old code that checks for empty or single-element lists, it will work fine, but if you don't, you'll get the expected result. (06-21-2014 02:13 AM)ttw Wrote: Similarly for the produce (but here the product of an empty list is one rather than zero.)This I don't agree. The summation of an empty list should still give an error, because you don't know that the empty list would contain reals. What if it was a list of strings? The sum of that empty list should return an empty string then (""), but how do you distinguish between an empty list of reals and an empty list of strings? (06-21-2014 02:13 AM)ttw Wrote: A scalar should promote up to a list. For that matter, operations on conformable lists-of-lists should work (->Q works but addition doesn't.)I think scalars need to remain scalars. What I figured for newRPL was like this:
(I'm using the [[ ]] to mark intermediate evaluation steps that you wouldn't normally see). If you were to promote numbers to a list, then the operation of: { 1 X 3 } 1 + { [[1 {1} +]] [[X {1} +]] [[3 {1} +]] } { [[{1} {1} +]] [[{2} {1} +]] [[{X}??? {1} +]] } { { 2 } { 'X+1' } { 4 } } I promoted the 1 to a list, then I ended up with a number plus a list, so I had to promote the number too, and when I found the X then what do we do? We don't know that X is a scalar or not, so do we promote it? In this case I did, but I'm not sure I should. I think it's more natural to get { 2 'X+1' 4 } than { {2} {'X+1'} {4} } It looks like adding a number to a list ended up transposing it (if you think of a list as a matrix). Claudio |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)