How many integer numbers are in the vector 20.88 10 ¯2.3 0 .555 222 ¯0 2 3.3 9
?
I need to do it using APL.
Please also recommend any links to learn the APL language.
How many integer numbers are in the vector 20.88 10 ¯2.3 0 .555 222 ¯0 2 3.3 9
?
I need to do it using APL.
Please also recommend any links to learn the APL language.
You can check if a number x
is an integer with x=⌊x
, but of course APL processes entire arrays at a time, so using the name v
for your vector, v=⌊v
gives you a Boolean vector indicating integers (0 1 0 1 0 1 1 1 0 1
in your case) and +/v=⌊v
is the sum of the Boolean vector, that is the count of integers.
For learning APL, The APL Orchard is a good place to hang out. There are people there who can help you and an APL chat bot to evaluate small expression. The chat bot's profile has a collection of links to APL resources.
You can also find transcripts of the APL Cultivation lessons which were held in the APL Orchard.
1|x
is the division remainder when x
is divided by one. This gives you the fractional part of x
. If that fractional part is zero, x
is an integer: 0=1|x
. Continue as per the above method. TryAPL!