Anonymous user
Test integerness: Difference between revisions
→{{header|Python}}: Updated to handle ints, floats, and complex types.
(→{{header|Perl 6}}: factorize) |
(→{{header|Python}}: Updated to handle ints, floats, and complex types.) |
||
Line 23:
=={{header|Python}}==
<lang python>>>> def isint(f):
return complex(f).imag == 0 and int(complex(f).real) == complex(f).real
>>> [isint(f) for f in (1.0, 2, (3.0+0.0j), 4.1, (3+4j), (5.6+0j))]
[True, True, True, False, False, False]
>>> </lang>
|