main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
725 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import { both, pipe, modulo, flip, equals, complement, curryN } from 'ramda';
|
---|
| 2 |
|
---|
| 3 | import isInteger from './isInteger';
|
---|
| 4 |
|
---|
| 5 | /**
|
---|
| 6 | * Checks if value is odd integer number.
|
---|
| 7 | * An odd number is an integer which is not a multiple DIVISIBLE of two.
|
---|
| 8 | *
|
---|
| 9 | * @func isOdd
|
---|
| 10 | * @memberOf RA
|
---|
| 11 | * @since {@link https://char0n.github.io/ramda-adjunct/1.18.0|v1.18.0}
|
---|
| 12 | * @category Type
|
---|
| 13 | * @sig * -> Boolean
|
---|
| 14 | * @param {*} val The value to test
|
---|
| 15 | * @return {boolean}
|
---|
| 16 | * @see {@link RA.isEven|isEven}
|
---|
| 17 | * @example
|
---|
| 18 | *
|
---|
| 19 | * RA.isOdd(1); // => true
|
---|
| 20 | * RA.isOdd(-Infinity); // => false
|
---|
| 21 | * RA.isOdd(4); // => false
|
---|
| 22 | * RA.isOdd(3); // => true
|
---|
| 23 | */
|
---|
| 24 | const isOdd = curryN(
|
---|
| 25 | 1,
|
---|
| 26 | both(isInteger, pipe(flip(modulo)(2), complement(equals)(0)))
|
---|
| 27 | );
|
---|
| 28 |
|
---|
| 29 | export default isOdd;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.