[OpenSCAD] Length of vector members

doug moen doug at moens.org
Thu Sep 24 10:44:12 EDT 2015


The len() function is only defined for vectors and strings. It returns
undef for any other type of argument. Lots of code relies on this behaviour
so don't expect it to change.

On Thursday, 24 September 2015, L Boyd <lboyd at frontiernet.net> wrote:

> When using len() for the length of vector members, a single numeric value
> returns undef rather than 1.
>
> Examples:
>
>  a = [[1,2],3,"string"];
>
>  echoing the string part and lengths
>
>  ECHO: "a   = ", [[1, 2], 3, "string"], " length = ", 3
>  ECHO: "a[0] = ", [1, 2], " length = ", 2
>
>  so far so good, but
>
>  ECHO: "a[1]   = ", 3, " length = ", undef
>  ECHO: "a[0][1] = ", 2, " length = ", undef
>
>  no, it is not related to having a mixed vector
>
>  b=[5,4,3,1];
>
>  ECHO: "b   = ", [5, 4, 3, 1], " length = ", 4
>  ECHO: "b[0] = ", 5, " length = ", undef
>
>  for the string everything behaves great
>
>  ECHO: "a[2]   = ", "string", " length = ", 6
>  ECHO: "a[2][1]   = ", "t", " length = ", 1
>
>
>
>
> --
> View this message in context:
> http://forum.openscad.org/Length-of-vector-members-tp13971.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org <javascript:;>
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150924/775680ba/attachment-0002.html>


More information about the Discuss mailing list