-1- For "I want to find the integers in a vector of floating point numbers" this will do:
inr=: =<. NB. boolean 'is not real' ] v=. 1r3 1r2 1,(%:3),2 2.99 3 1p1 0.333333 0.5 1 1.73205 2 2.99 3 3.14159 inr v 0 0 1 0 1 0 1 0 (inr v) # v 1 2 3 fi=: (=<.) # ] fi v 1 2 3 -2- For "Use the mark vector to find the perfect squares in a" this will be one solution: b=. %: a=. >: i.17 fi=. (=<.) @ %: # ] fi a 1 4 9 16 fi1=. ] #~ (=<.) @ %: fi1 a 1 4 9 16 fi p: i.17 NB. lots of integers, but no square ... -M At 2018-06-12 20:40, you 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
---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm