isodd ~master

Parity tests with low cognitive load


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

isodd(3d) - 3d

NAME

isodd - Parity tests with low cognitive load

SYNOPSIS

import isodd : isOdd, isEven;

bool isOdd(T)(T n);

bool isEven(T)(T n);

DESCRIPTION

isOdd() returns true when given an even integral type or a type with a compatible overloading of opBinary!("&"). isEven() returns false in all cases where isOdd() would return true.

RETURN VALUE

These functions return true or false.

CONFORMING TO

The mathematical property of parity.

BUGS

These functions cannot be applied to floating-point numbers. These functions have not been tested against any indefinite-precision number libraries. These functions classify 1 as odd, violating the ancient Greek understanding that 1 is neither even nor odd.

EXAMPLE

#! /usr/bin/env rdmd
import std.stdio, std.conv, isodd;
import core.stdc.stdlib : exit;

void main(string[] args) {
    void usage() { stderr.writefln("usage: %s <number>", args[0]); exit(1); }

    if (args.length != 2) usage();
    try {
        writeln(isOdd(to!int(args[1])));
    } catch (std.conv.ConvException e) {
        usage();
    }
}

SEE ALSO

isfourtytwo(3d), iszero(3d), is_number_of_beast(3d), divisibleby(3d), only_divisible_by_itself_and_one(3d), readable_math(3d), may_resemble_phone_number(3d), may_resemble_SSN(3d), may_resemble_CCN(3d), may_resemble_luggage_combination(3d), politically_sensitive_numbers(3d)

RATIONALE

https://forum.dlang.org/thread/[email protected]

FUTURE DIRECTIONS

None.

COLOPHON

This page is part of the 0.1.0 release of the isodd DUB package. This package can be found at https://code.dlang.org/packages/isodd/.

D - April 13, 2019

Authors:
  • Julian Fondren
Dependencies:
none
Versions:
0.1.0 2019-Apr-13
~master 2019-Nov-24
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 12 downloads total

Score:
0.1
Short URL:
isodd.dub.pm