Igor Schein on Mon, 18 Nov 2002 21:25:33 -0500 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
extension of vecextract() |
Hi, let's say I have a vector and I wanna insert an element into it: \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ? v=["a","b","c","d"]; \\ inserting an element at 3rd position: ? concat([vecextract(v,3),[1],vecextract(v,12)]) ["a", "b", 1, "c", "d"] \\ or ? w=[1,2];concat([vecextract(v,w),[1],vecextract(v,eval(setminus(Set(vector(4,k,k)),Set(w))))]) ["a", "b", 1, "c", "d"] \\ or ? concat([vecextract(v,"1..2"),[1],vecextract(v,"3..4")]) ["a", "b", 1, "c", "d"] \\ however, if I wanna insert it in the beginning or in the end: ? concat([vecextract(v,15),[1],vecextract(v,0)]) ["a", "b", "c", "d", 1] \\ or ? w=[1,2,3,4];concat([vecextract(v,w),[1],vecextract(v,eval(setminus(Set(vector(4,k,k)),w)))]) ["a", "b", "c", "d", 1] \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ There's no way to do it with ".." mechanism So maybe it's a good idea to extend ".." mechanism to be consistent with the other two? Thanks Igor