Algorithmic Modelling with Grasshopper by Mohamad Khabazi

Page 32

28

Data sets and Math

3_5_Boolean Data types Data is not limited to Numbers. There are other data types that are useful for other purposes in programming and algorithms. Since we are dealing with algorithms, we should know that the progress of an algorithm is not always linear. Sometimes we want to decide whether to do something or not. Programmers call it conditional statements. And we want to see whether a statement meets certain criteria or not to decide what to do next. The response of the conditional ‘question’ is a simple yes or no. in algorithms we use Boolean data to represent these responses. Boolean values are data types which represent True (yes) or False (no) values only. If the statement meets the criteria, the response is True, otherwise False. As you will see later, this data type is very useful in different cases when you want to decide about something, select some objects by certain criteria, sort objects, etc.

Fig.3.13. Here I generated ten <random> values and by a <function> component I want to see if these numbers are less than a certain <Upper_limit> or not. As you see the <function> is simply X>Y and whenever the numbers meet the criteria, the function passes True to the <panel>.

Chapter 3

Fig.3.14.a. For the next step, I used a <Modulus> component (Scalar > Operators > Modulus) to find the remainder of the division of the Random values by <2> and I pass the result to a <function> to see if this remainder =0 or not (f(x)=x=0), simply means whether the number is even or not. As you see the result is another <panel> of True/False values.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.