How to check if a value is equal or not equal to one of multiple values in Lua?

Your problem stems from a misunderstanding of the or operator that is common to people learning programming languages like this. Yes, your immediate problem can be solved by writing x ~= 0 and x ~= 1, but I’ll go into a little more detail about why your attempted solution doesn’t work. When you read x … Read more

Multiple IF statements between number ranges

It’s a little tricky because of the nested IFs but here is my answer (confirmed in Google Spreadsheets): =IF(AND(A2>=0, A2<500), “Less than 500”, IF(AND(A2>=500, A2<1000), “Between 500 and 1000”, IF(AND(A2>=1000, A2<1500), “Between 1000 and 1500”, IF(AND(A2>=1500, A2<2000), “Between 1500 and 2000”, “Undefined”))))

What use does if_/3 have?

In old-fashioned Prolog code, the following pattern arises rather frequently: predicate([], …). predicate([L|Ls], …) :- condition(L), then(Ls, …). predicate([L|Ls], …) :- \+ condition(L), else(Ls, …). I am using lists here as an example where this occurs (see for example include/3, exclude/3 etc.), although the pattern of course also occurs elsewhere. The tragic is the following: … Read more

How to do a single line If statement in VBScript for Classic-ASP?

The conditional ternary operator doesn’t exist out of the box, but it’s pretty easy to create your own version in VBScript: Function IIf(bClause, sTrue, sFalse) If CBool(bClause) Then IIf = sTrue Else IIf = sFalse End If End Function You can then use this, as per your example: lunchLocation = IIf(dayOfTheWeek = “Tuesday”, “Fuddruckers”, “Food … Read more