On Fri, 09 Feb 2007 10:18, Richard H. McCullough wrote: You were probably getting the equivalent of
i : +3 in other words 1 : 3, 4 : 3, 7 : 3, 10 : 4, ..... In (Un)Icon, string and array positions are considered to be "before" or "between" the characters or elements: [caution - may need a fixed-width font to see this clearly] a b c d e 1 2 3 4 5 6 which has great value during string scanning. If you ask for the Nth item of a string or array, eg "abcde"[2] then it's understood that the element after the point is fetched, eg "b" in this example. So far so good, since it matches the expected convention from other languages. When you ask for "abcde"[2 : 4], it's the elements between the marks, so you'd get "bc". When you write > But instead of getting 1:3, 4:6, 7:9, 10:12 > I got 1:2, 3:3, 6:3, 9:3 Strictly speaking, you are wrong, if your 2nd line is supposed to be pure Icon syntax. I think you mean I got (1,2), (3,3), (6,3), (9,3) since you are still thinking like other languages eg Perl, Basic, Java, etc. The difference is pedantic, but important; thinking of indexes in Icon is unique. Go back over what I've written so far; the concept of pointing to the gap between characters is essential to understand. Once you understand, you'll be able to see why you got strings of length 2, 1, etc The other point you need to know is that for M : N, if M > N then they are simply swapped before giving you the string. It seems you are already aware of this, but I'm just confirming. As to the tokens chosen as the additive-index operator: It's precisely because of the possible ambiguity between 3 :+ 5 and 3 : +5 when written as 3:+5 that the operator was NOT chosen to look like :+ but instead +: which cannot possibly be any other legal part of the syntax. In my head, I call +: the "additive index" operator. It makes it easy to think naturally in (Un)Icon. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Unicon-group mailing list Unicon-group@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/unicon-group