Re: & and append(), sequence slicing, shrouding
- Posted by isaac <isaaca at MINDSPRING.COM> Nov 08, 1998
- 474 views
I have to disagree with your suggestion that {{1,2},{3,4}}&5 --> {{1,2,5},{3,4,5}} I actually like the & operator. My suggestion would be to optimize s1&{s2} to be as fast as append(s1,s2), and we wouldn't need the append function at all. I do agree with the && suggestion though; in fact I suggested this format for all binary operators a few months ago: s1={{a,b},{c,d}} s2={e,f} s1&s2: {{a,b},{c,d},e,f,g} s1&{s2}: {{a,b},{c,d},{e,f}} s1&&s2: {{a,b,e,f},{c,d,e,f}} s1+s2: {{a+e,b+e},{c+f,d+f}} s1++s2: {{a,b}+{e,f},{c,d}+{e,f}} --> {{a+e,b+f},{c+e,d+f}} This could be expanded to accept +++, etc, with each + adding one level deeper on which to operate. a command such as: ?{1,2,{{3,4}}}+++{1,2} would either skip the first two levels and begin operating on the third, producing: {1,2,{{4,6}}} or would cause an error. A common use for deep operators would be sets nof coordinates. As for s[1..3][2], I believe it has been suggested before, and I like it; it would allow sequences to represent true multidimentional fields, as opposed to lists of lists as they are now, but it seems like it'd be tough to implement with any efficiency. Isaac