[Scilab-users] convert vector to list

Samuel Gougeon sgougeon at free.fr
Fri Feb 19 16:53:04 CET 2021


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20210219/5f8c0f7d/attachment.htm>


More information about the users mailing list