isodd 0.1.0

Parity tests with low cognitive load


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

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 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(2d), iszero(2d), is_number_of_beast(2d), divisibleby(2d), only_divisible_by_itself_and_one(2d), readable_math(2d), may_resemble_phone_number(2d), may_resemble_SSN(2d), may_resemble_CCN(2d), may_resemble_luggage_combination(2d), politically_sensitive_numbers(2d)

RATIONALE

https://forum.dlang.org/thread/sudscchdjotuzmhqcntq@forum.dlang.org

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
Show all 1 versions
Download Stats:
  • 0 downloads today

  • 2 downloads this week

  • 2 downloads this month

  • 3 downloads total

Score:
0.0
Short URL:
isodd.dub.pm