Need to input variable number of variables in TI-nspire CX CAS - ti-basic

I want to write a TIBasic program for the nspire CS CAS which will perform simple finite element analysis. In order to do this, I need to be able to input a non-specific number of variables since the number of members in a problem will vary.
Is there a command or trick I can use to program variables k1,k2,k3,...,kn?

Unfortunately, I don't think there's a way to use multiple variables like that. You might be able to use a list and store all your variables there. Lists can only hold up to 999 elements though, so that'll limit what you can do.

Related

Is there some standard for handling sets of ranges of numbers?

When you open the print dialog of an editor, you typically get a field for specifying which pages you want to print - which can be multiple ranges, e.g.: "5,11,31-33"
Now, there are other scenarios in which this kind of input from a user is relevant - especially in configuration files for sequential or iterative processes where you want to qualify which iterations or elements a certain action or feature should apply to.
However, I'm not aware of a name for this kind of strings; nor of an accepted standard format/convention for them (i.e. can you add spaces? Can you use semicolons instead of commas? Must the ranges be sorted? Are overlaps allowed and are they maintained or discarded? Can ranges use ".." instead of "-"? Can you range down instead of up? etc.).
Is there some such convention or such standard?
My motivation is double: I need to parse such ranges in a piece of code I'm looking at, any I want both to do it correctly (or rather per-convention), and secondly to go look for parsing functionality in existing libraries. Right now I don't even have a name to go on.

Efficient access to last value in large list in python

I am using a large list in my python script and need to access the last value of this list very often, while the list doesn't change that much. Should I simply access it directly (longList[-1]) or is it preferable to assign the last value of the list to a variable (lastValue = longList[-1]) and use this variable instead. Of course I have to update the variable when the list changes.
From a functionality point of few it is the same, I am more concerned about the performance gain it could bring.
List access takes O(1) time. So, there is no need to assign it to a variable.

How Can I Apply Different Formats Based on Data Values

I'm revising a data step that resides in a SAS macro. Currently a single format is used to create a new field for the whole dataset. I'm attempting to revise it to where a different format will be used on different subsets of the dataset. (I have a field that indicates which subset the row belongs to.)
I could do this with a bunch of if statements, but that would need to be changed if the number of categories changes in the future. I think I can achieve what I want by using call symput and resolve but I'm unsure what the syntax for that would be. Can I achieve this without resorting to if statements?
Your question isn't perfectly clear, but if you want to do something like
newvar = put(oldvar,MYFMT.)
->
if x=1 then newvar=put(oldvar,MYFMT.);
else newvar=put(oldvar,MYFMT2.);
But without all of the if statements, you can use PUTN or PUTC, which allows you to specify the format at runtime.
newvar = putn(oldvar,fmtvar); *optionally can specify w and d as separate arguments also;

Variable input for JMeter Load testing?

I need to load test a service I've developed but I need the data that I post to the web service to have some variance.
I've set up Thread with an Http Request and I've the parameter I need to set but I can't see how I'd go about changing the contents of the HTTP parameter from request to request.
Ideally I'd like to feed in a list of data Items and have JMeter iterate through them.
Prepare kind of csv-file with list of your test-params and use it to parametrize your test-samplers, using at least the following:
CSV Data Set Config
Explained example here, simple example here.
Jmeter functions: __CSVRead, __StringFromFile.
Variables From CSV sampler from jmeter-plugins.
One way would be to prepare a CSV file with all the values that you will need. There are a multitude of different ways to use it afterwards. Alies Belik's answer listed most of them. The drawback of the CSV approach, however, is that you need to generate the list of values, and in some tests you can't simply reuse it without cleaning up/reinitializing the back-end database.
Another option are the functions for generating random values, usually paired with "User Defined Variables" controller.
__Random for generating numbers in a given range.
__RandomString for generating random strings of a given length and containing a set of characters.
This is a powerful mechanism, but I find it somewhat cumbersome and clunky.
For simple variables, like generating username/password/e-mail combinations, I prefer and find it easier to use the Random Variable config element. It's available since Jmeter 2.3.3. You add it to your thread group and specify a variable to store the random value for each thread. You can later reference this variable in your HTTP sampler, in the GET/POST parameters of the request, by specifying the Value of the parameter to be testuser-${rnd} for username, testpass-${rnd} for password. Each thread will get a different value of ${rnd} so there is a small chance (but there is still a chance) that you will get duplicate values (users).
Besides the functions mentioned in #zorlem answer, You can also use:
__UUID for generating a pseudo random type 4 Universally Unique IDentifier, if you need to generate random & unique strings.

XPath Query in JMeter

I'm currently working with JMeter in order to stress test one of our systems before release. Through this, I need to simulate users clicking links on the webpage presented to them. I've decided to extract theese links with an XPath Post-Processor.
Here's my problem:
I have an a XPath expression that looks something like this:
//div[#data-attrib="foo"]//a//#href
However I need to extract a specific child for each thread (user). I want to do something like this:
//div[#data-attrib="foo"]//a[position()=n]//#href
(n being the current index)
My question:
Is there a way to make this query work, so that I'm able to extract a new index of the expression for each thread?
Also, as I mentioned, I'm using JMeter. JMeter creates a variable for each of the resulting nodes, of an XPath query. However it names them as "VarName_n", and doesn't store them as a traditional array. Does anyone know how I can dynamicaly pick one of theese variables, if possible? This would also solve my problem.
Thanks in advance :)
EDIT:
Nested variables are apparently not supported, so in order to dynamically refer to variables that are named "VarName_1", VarName_2" and so forth, this can be used:
${__BeanShell(vars.get("VarName_${n}"))}
Where "n" is an integer. So if n == 1, this will get the value of the variable named "VarName_1".
If the "n" integer changes during a single thread, the ForEach controller is designed specifically for this purpose.
For the first question -- use:
(//div[#data-attrib="foo"]//a)[position()=$n]/#href
where $n must be substituted with a specific integer.
Here we also assume that //div[#data-attrib="foo"] selects a single div element.
Do note that the XPath pseudo-operator // typically result in very slow evaluation (a complete sub-tree is searched) and also in other confusing problems ( this is why the brackets are needed in the above expression).
It is recommended to avoid using // whenever the structure of the document is known and a complete, concrete path can be specified.
As for the second question, it is not clear. Please, provide an example.

Resources