algorithmic modeling for Rhino
I would like to know why the index of the first item in a list is "0" and not "1".
Apart from making tree structures even more difficult to work with and generating bugs when one has forgotten to add a "-1" component each time you need the "N th" component in a list, what is it good for ?
Is it just a programmer's frivolity, or does it actually have a practical reason ?
I can see that it allows to use a boolean input to select either the first (N°0) item, or the second (N°1), but other than that... ?
Cheers,
Tags:
Hello Nikos,
Thank you for these two examples.
In both cases, I learned something useful !
Yeah, conditional logic is quite difficult, and iteration logic (except when it just happens to work correctly by default) is even more difficult and often impossible.
On the other hand, this particular example is not very good, because the number of components needed (3, not counting the text constants) is about the same as the number of lines of text you'd need in regular code... The only way this can be easier would be if the Smaller Than component outputted an integer which would represent three different states...
To me, your proposed solution is actually rather elegant. And if you only care about Smaller Than or Not Smaller Than it gets simpler still.
When it comes to conditionals, in my experience the hardest part is performing some operation on certain elements in a collection while leaving others unmolested, without messing with the order of the elements.
When introducing Grasshopper/programming to other architects, its common to hear them complain and get confused about zero based numbering, which is puzzling since its the same way building floors are numbered in most places.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by