Module "Integer.curry"

A collection of common operations on integer numbers. Most operations make no assumption on the precision of integers. Operation bitNot is necessarily an exception.

Author: Sergio Antoy

Version: March 20, 2006


 Exported names:

Functions:
abs | binomial | bitAnd | bitNot | bitOr | bitTrunc | bitXor | even | factorial | ilog | isqrt | max3 | maxlist | min3 | minlist | odd | pow


 Summary of exported functions:

pow  :: Int -> Int -> Int  deterministic rigid
          The value of pow a b is a raised to the power of b.
ilog  :: Int -> Int  deterministic rigid
          The value of ilog n is the floor of the logarithm in the base 10 of n.
isqrt  :: Int -> Int  deterministic rigid
          The value of isqrt n is the floor of the square root of n.
factorial  :: Int -> Int  deterministic rigid
          The value of factorial n is the factorial of n.
binomial  :: Int -> Int -> Int  deterministic rigid
          The value of binomial n m is n*(n-1)*...*(n-m+1)/m*(m-1)*...1 Fails if m <= 0 or n < m.
abs  :: Int -> Int  deterministic rigid
          The value of abs n is the absolute value of n.
max3  :: a -> a -> a -> a  deterministic 
          Returns the maximum of the three arguments.
min3  :: a -> a -> a -> a  deterministic 
          Returns the minimum of the three arguments.
maxlist  :: [a] -> a  deterministic flexible
          Returns the maximum of a list of integer values.
minlist  :: [a] -> a  deterministic flexible
          Returns the minimum of a list of integer values.
bitTrunc  :: Int -> Int -> Int  deterministic 
          The value of bitTrunc n m is the value of the n least significant bits of m.
bitAnd  :: Int -> Int -> Int  deterministic rigid
          Returns the bitwise AND of the two arguments.
bitOr  :: Int -> Int -> Int  deterministic rigid
          Returns the bitwise inclusive OR of the two arguments.
bitNot  :: Int -> Int  deterministic 
          Returns the bitwise NOT of the argument.
bitXor  :: Int -> Int -> Int  deterministic rigid
          Returns the bitwise exclusive OR of the two arguments.
even  :: Int -> Bool  deterministic 
          Returns whether an integer is even
odd  :: Int -> Bool  deterministic 
          Returns whether an integer is odd

 Imported modules:

Prelude

 Exported datatypes:


 Exported functions:

pow :: Int -> Int -> Int  deterministic rigid

The value of pow a b is a raised to the power of b. Fails if b < 0. Executes in O(log b) steps.

Example call:  (pow a b)

Parameters:
a - The base.
b - The exponent.
Returns:
a raised to the power of b.
Further infos:

ilog :: Int -> Int  deterministic rigid

The value of ilog n is the floor of the logarithm in the base 10 of n. Fails if n <= 0. For positive integers, the returned value is 1 less the number of digits in the decimal representation of n.

Example call:  (ilog n)

Parameters:
n - The argument.
Returns:
the floor of the logarithm in the base 10 of n.
Further infos:

isqrt :: Int -> Int  deterministic rigid

The value of isqrt n is the floor of the square root of n. Fails if n < 0. Executes in O(log n) steps, but there must be a better way.

Example call:  (isqrt n)

Parameters:
n - The argument.
Returns:
the floor of the square root of n.
Further infos:

factorial :: Int -> Int  deterministic rigid

The value of factorial n is the factorial of n. Fails if n < 0.

Example call:  (factorial n)

Parameters:
n - The argument.
Returns:
the factorial of n.
Further infos:

binomial :: Int -> Int -> Int  deterministic rigid

The value of binomial n m is n*(n-1)*...*(n-m+1)/m*(m-1)*...1 Fails if m <= 0 or n < m.

Example call:  (binomial n m)

Parameters:
n - Argument.
m - Argument.
Returns:
the binomial coefficient of n over m.
Further infos:

abs :: Int -> Int  deterministic rigid

The value of abs n is the absolute value of n.

Example call:  (abs n)

Parameters:
n - The argument.
Returns:
the absolute value of n.
Further infos:

max3 :: a -> a -> a -> a  deterministic 

Returns the maximum of the three arguments.

Example call:  (max3 n m p)

Parameters:
n - Argument.
m - Argument.
p - Argument.
Returns:
the maximum among n, m and p.

min3 :: a -> a -> a -> a  deterministic 

Returns the minimum of the three arguments.

Example call:  (min3 n m p)

Parameters:
n - Argument.
m - Argument.
p - Argument.
Returns:
the minimum among n, m and p.

maxlist :: [a] -> a  deterministic flexible

Returns the maximum of a list of integer values. Fails if the list is empty.

Example call:  (maxlist l)

Parameters:
l - The list of values.
Returns:
the maximum element of l.
Further infos:

minlist :: [a] -> a  deterministic flexible

Returns the minimum of a list of integer values. Fails if the list is empty.

Example call:  (minlist l)

Parameters:
l - The list of values.
Returns:
the minimum element of l.
Further infos:

bitTrunc :: Int -> Int -> Int  deterministic 

The value of bitTrunc n m is the value of the n least significant bits of m.

Example call:  (bitTrunc n m)

Parameters:
n - Argument.
m - Argument.
Returns:
m truncated to the n least significant bits.

bitAnd :: Int -> Int -> Int  deterministic rigid

Returns the bitwise AND of the two arguments.

Example call:  (bitAnd n m)

Parameters:
n - Argument.
m - Argument.
Returns:
the bitwise and of n and m.
Further infos:

bitOr :: Int -> Int -> Int  deterministic rigid

Returns the bitwise inclusive OR of the two arguments.

Example call:  (bitOr n m)

Parameters:
n - Argument.
m - Argument.
Returns:
the bitwise inclusive or of n and m.
Further infos:

bitNot :: Int -> Int  deterministic 

Returns the bitwise NOT of the argument. Since integers have unlimited precision, only the 32 least significant bits are computed.

Example call:  (bitNot n)

Parameters:
n - Argument.
Returns:
the bitwise negation of n truncated to 32 bits.

bitXor :: Int -> Int -> Int  deterministic rigid

Returns the bitwise exclusive OR of the two arguments.

Example call:  (bitXor n m)

Parameters:
n - Argument.
m - Argument.
Returns:
the bitwise exclusive of n and m.
Further infos:

even :: Int -> Bool  deterministic 

Returns whether an integer is even

Example call:  (even n)

Parameters:
n - Argument.
Returns:
whether n is even.

odd :: Int -> Bool  deterministic 

Returns whether an integer is odd

Example call:  (odd n)

Parameters:
n - Argument.
Returns:
whether n is odd.


Generated by CurryDoc (Version 0.4.1 of June 7, 2007) at Aug 28 15:25:28 2008