Karim BELABAS on Tue, 19 Nov 2002 23:52:20 +0100 (MET)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: extension of vecextract()


On Mon, 18 Nov 2002, Igor Schein wrote:
> 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?

I don't get it. What exact command would you like to run, and with what
expected result ?

[ Btw, what's wrong with concat(v, [1]), concat([1], v) ? ]

    Karim.
-- 
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
--
PARI/GP Home Page: http://www.parigp-home.de/