Check type of variable within Ti-Nspire function - ti-nspire

In Javascript there is the string typeof variable which returns either: number, string, array, object.
Is there a similar function I can run in the Ti-Nspire to tell if the variable is a number, string, or matrix?

Yes, gettype(var) function will return the string with variable type in it ("LIST", "MAT", "EXPR", "NUM", "STR", or "NONE")

No, but if you give an example of why you want to do do this, somebody may be able to help you.
Edit: An update of the language has added a function that solves OP's problem, making this answer out of date.

Related

Apache AGE - Creating Functions With Multiple Parameters

I was looking inside the create_vlabel function and noted that to get the graph_name and label_name it is used graph_name = PG_GETARG_NAME(0) and label_name = PG_GETARG_NAME(1). Since these two variables are also passed as parameters, I was thinking that, if I wanted to add one more parameter to this function, then I would need to use PG_GETARG_NAME(2) to get this parameter and use it in the function's logic. Is my assumption correct or do I need to do more tweaks to do this?
You are correct, but you also need to change the function signature in the "age--1.2.0.sql" file, updating the arguments:
CREATE FUNCTION ag_catalog.create_vlabel(graph_name name, label_name name, type new_argument)
RETURNS void
LANGUAGE c
AS 'MODULE_PATHNAME';
Note that all arguments come as a "Datum" struct, and PG_GETARG_NAME automatically converts it to a "Name" struct. If you need an argument as int32, for example, you should use PG_GETARG_INT32(index_of_the_argument), for strings, PG_GETARG_CSTRING(n), and so on.
Yes, your assumption is correct. If you want to add an additional parameter to the create_vlabel function in PostgreSQL, you can retrieve the value of the third argument using PG_GETARG_NAME(2). Keep in mind that you may need to make additional modifications to the function's logic to handle the new parameter correctly.
The answers given by Fahad Zaheer and Marco Souza are correct, but you can also create a Variadic function, with which you could have n number of arguments but one drawback is that you would have to check the type yourself. You can find more information here. You can also check many Apache Age functions made this way e.g agtype_to_int2.

AnyLogic not properly reading from Excel String Values

I've been seeing a weird AnyLogic behavior where I cannot use boolean operations properly with Excel. For example, if I assign a string value of "x" to a variable from Excel and then check in AnyLogic if that variable is equal to "x", AnyLogic returns false as if the "x" from Excel is different than "x" in AnyLogic.
For simplicity I am sharing a very simplified model highlighting the issue.
https://wetransfer.com/downloads/eaa042a4999021c11f4396759a3c9da020210123154728/550611
Has anyone faced such an issue?
You can/should only use "==" with primitives (int, double, boolean) but with classes you need to use equals(), and String is not a primitive.
Like this:
if(excelFile.getCellStringValue(1, 1, 1).equals("x"))

What does colon do in a php function boolean parameter do?

It's a newbie question I suppose but please explain what this code states with the ":"
switchURL(changeUrl: boolean = false){
if (changeUrl){
location.goTo(..............)
}
}
This function is called without parameters - switchURL(). My misunderstanding is bigger having in mind that the if statement works as changeURL is true.
Thank you in advance!
Regardless of the programming language, your code seems to be defining a function.
switchURL(changeUrl: boolean = false) {…}
If this syntax is correct (I don't know), its expected meaning would be that switchURL accepts an argument called changeUrl of type boolean and its default value will be false.
So, if you call switchURL() without any arguments, the location.goTo(…) code won't be executed because the argument (and therefore the condition) will be false.

Expected parameter scala.Option<Timestamp> vs. Actual argument Timestamp

This is probably a very silly question, but I have a case class which takes as a parameter Option[Timestamp]. The reason this is necessary is because sometimes the timestamp isn't included. However, for testing purposes I'm making an object where I pass in
Timestamp.valueOf("2016-01-27 22:27:32.596150")
But, it seems I can't do this as this is an actual Timestamp, and it's expecting an Option.
How do I convert to Option[Timestamp] from Timestamp. Further, why does this cause a problem to begin with? Isn't the whole benefit of Option that it could be there or not?
Thanks in advance,
Option indicates the possibility of a missing value, but you still need to construct an Option[Timestamp] value. There are two subtypes for Option - None when there is no value, and Some[T] which contains a value of type T.
You can create one directly using Some:
Some(Timestamp.valueOf("2016-01-27 22:27:32.596150"))
or Option.apply:
Option(Timestamp.valueOf("2016-01-27 22:27:32.596150"))

Using a parameter value as a CDate() function input

I have a parameter {?Calendar Year} that takes on year values (2014,2015, etc.) that I would like to use in a formula. I would like it to function how one might think this would work:
{table.date}>CDate({?Calendar Year},01,01).
Does anyone know how I can accomplish this?