Lists and list lengths

Hi there, Mike. I’m not sure why square brackets are giving you an error, but that’s the syntax you want for filtering.

The condition behavior isn’t a consequence of JavaScript interaction. It’s just that conditions “broadcast” over lists in the calculator the same way that other operations do, and conditions either evaluate to 1 or NaN/undefined. So if you have a list of conditions with a mix of true and false results, you get a list with a mix of 1s an undefineds. Nothing about this changes the list length (though as you mentioned, points with undefined coordinates or curves with undefined parameters won’t plot).

If you want to filter a list, the way you do that is with our indexing syntax (square brackets). I’m not sure why that’s giving you an error, but it shouldn’t. Here’s a link to a graph with some exposition. And here’s another graph with a bunch of examples of fancy ways to work with lists, including methods/syntax that alter list length.

2 Likes