[Scilab-users] convert vector to list

classic Classic list List threaded Threaded
4 messages Options
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] convert vector to list


Dear All,

Is there a Scilab function to convert a vector to a list?

If x is a vector, this code

L = list();
for n=1:length(x)
    L(n) = x(n);
end

seems to work, but it would be nice to have a primitive doing this more efficiently. I don't seem to be able to find it.

Regards,

Federico Miyara

Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: convert vector to list

vec2list() ?

Le 18/02/2021 à 19:34, Federico Miyara a écrit :

Dear All,

Is there a Scilab function to convert a vector to a list?

If x is a vector, this code

L = list();
for n=1:length(x)
    L(n) = x(n);
end

seems to work, but it would be nice to have a primitive doing this more efficiently. I don't seem to be able to find it.

Regards,

Federico Miyara

Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: convert vector to list


He he

Sometimes the answer is so 'obvious' ... it's just that the user never heard about it before. Myself included.

/Claus

On 18-02-2021 19:37, Stéphane Mottelet wrote:

vec2list() ?

Le 18/02/2021 à 19:34, Federico Miyara a écrit :

Dear All,

Is there a Scilab function to convert a vector to a list?

If x is a vector, this code

L = list();
for n=1:length(x)
    L(n) = x(n);
end

seems to work, but it would be nice to have a primitive doing this more efficiently. I don't seem to be able to find it.

Regards,

Federico Miyara

Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: convert vector to list

In reply to this post by fmiyara
Le 18/02/2021 à 19:34, Federico Miyara a écrit :

Dear All,

Is there a Scilab function to convert a vector to a list?

If x is a vector, this code

L = list();
for n=1:length(x)
    L(n) = x(n);
end

seems to work, but it would be nice to have a primitive doing this more efficiently. I don't seem to be able to find it.


vec2list()  is a macro instead of a built-in, but it aims to do the job:

--> n = 3;
--> v = rand(1,n)
 v  =
   0.2113249   0.7560439   0.0002211

--> vec2list(v,ones(n,2))
 ans  =
  
    (1) = 0.2113249
      (2) = 0.7560439
      (3) = 0.0002211

https://help.scilab.org/docs/6.1.0/en_US/vec2list.html

Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users