1. suggestion for 2.3
- Posted by aku at inbox.as May 07, 2001
- 478 views
if I have a sequence: seq = { { 1, 2, 3}, { 4, 5, 6}, { 7, 8, 9}, {10,11,12} } and i want to get the first column ( 1,4,7,10 ) in version 2.2 i must use at least 1 'for' statement. I suggest this for version 2.3: a = seq[][1] -- a = {1,4,7,10} a = seq[][1..2] -- a = {{1,2},{4,5},{7,8},{10,11}} a = seq[][1..2][1] -- a = {1,2} a = seq[] -- a = seq but if: seq = { { 1, 2, 3 }, { 4, 5 }, { 6 } } a= seq[][2] -- subscript 2 out of bounds it is very useful, for example: findrep = { { "Halo", "Helo" }, { "This", "that" }, { "bmp", "jpg" }, { "find", "replace" } } so we can use: for i = 1 to length(words) do at = find( words[i], findrep[][1] ) if at then words[i] = findrep[at][2] end if end for
2. Re: suggestion for 2.3
- Posted by Irv Mullins <irvm at ellijay.com> May 07, 2001
- 472 views
On Mon, 07 May 2001, aku at inbox.as wrote: > if I have a sequence: > > seq = > { > { 1, 2, 3}, > { 4, 5, 6}, > { 7, 8, 9}, > {10,11,12} > } > > and i want to get the first column ( 1,4,7,10 ) > in version 2.2 i must use at least 1 'for' statement. > > I suggest this for version 2.3: > > a = seq[][1] -- a = {1,4,7,10} > a = seq[][1..2] -- a = {{1,2},{4,5},{7,8},{10,11}} > a = seq[][1..2][1] -- a = {1,2} > a = seq[] -- a = seq > This would indeed be useful in many ways - and it has been discussed here before. So much so that it's been given a name "vertical slicing". We can only hope that it's in Rob's list. Regards, Irv