If the original list is floating point as indicated- then intolerant
comparison may not be possible. If there are true integers (e.g 2 vs
2.00000.....) does the square/square root operation differentiate in a
mixed floating point and integer vector?. I note that Skip's 'a' vector
is a vector of integers so it appears that the return result is only the
squares that are integer-not the integers in the original vector 'a=.1+i.20
fi 1+i.20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
If the values of the tolerantly integer items are needed then modify fi
given by Henry
f=: (=<.) #]
f 1.0 2.4 3.0 _1.0 3.000000000010000000000000001 _3.1
1 3 _1
f 1.0 2.4 3.0 _1.0 3.00000000000000000000000001 _3.1
1 3 _1 3
On 2018-06-12 1:42 PM, Henry Rich wrote:
fi =: (= <.)
Consider whether you want intolerant comparison.
Henry Rich
On 6/12/2018 4:40 PM, Skip Cave wrote:
I want to find the integers in a vector of floating point numbers, by
generating a boolean marking vector indicating the locations of the
integers in the floating-point vector:
Generate a vector of integers & store in a, and generate a second
vector of
floating and integer numbers by taking the square root of a:
b =. %: a=. 1+i.20
Create an integer-finding/marking verb:
fi =. 3 :'(<.y)=y'
Use 'fi' to find the integers in b:
fi b
1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0
Use the mark vector to find the perfect squares in a, by finding the
integers in b:
a#~ fi b
1 4 9 16
My question is: What are some tacit ways to implement the fi verb?
Skip
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by AVG.
http://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm