I don't think so. But let me give an example.
Let's say x is an array of strings and y is a string, I would like to have the
function return zero if x doesn't contains an element equal to y and the position in
the array if an element equals y.
This is easy if you know the data type ahead of time, but it would be neet if the function
could check that for itself. that way one function works for all data types that can be
stored in an array.
Artur,
What you are suggesting is fine for a matrix, but I was thinking about other data types?
Logan
Sent from my T-Mobile 4G LTE Device
-------- Original message --------
From: "Artur T." <artur.tarassow(a)googlemail.com>
Date:11/25/2014 2:18 PM (GMT-06:00)
To: gretl-devel(a)lists.wfu.edu
Cc:
Subject: Re: [Gretl-devel] is there an inarray function?
Do you mean something like:
# Replace NANs in matrix by zeros
M = isnan(M) ? 0 : M
# Replace zeros in matrix OUT by 999
M = OUT ? OUT : 999
# Check for conditions and replace zero by 1 if the condition v .< x is met (x and v
are both matrices)
mtmp = {}
mtmp = (v .< x)
Artur
On 25.11.2014 21:13, Logan Kelly wrote:
Hello,
I need a function the tests if variable is in an array (sorry for the poor wording of this
sentence). What I mean by this is a function that compares each element of an array to a
variable and returns 0 if no elements of the array are equal and the position in the array
of the first instance of equality. So here are my question:
1. Dose such a function exist? (I haven’t found one, but I thought I should ask)
2. If not, coding it up is no problem, but I need a way to check the data type of
variable. Is there such a command?
3. Is there a way, other than using a bundle, to pass a variable of unknown data type to a
function?
Thanks,
Logan
_______________________________________________
Gretl-devel mailing list
Gretl-devel@lists.wfu.edu<mailto:Gretl-devel@lists.wfu.edu>
http://lists.wfu.edu/mailman/listinfo/gretl-devel