husk-scheme-3.14: R5RS Scheme interpreter, compiler, and library.

Portabilityportable
Stabilityexperimental
Maintainergithub.com/justinethier
Safe HaskellSafe-Inferred

Language.Scheme.Numerical

Contents

Description

This module implements the numerical tower.

Synopsis

Generic functions

numSub :: [LispVal] -> ThrowsError LispValSource

Subtract the given numbers

numMul :: [LispVal] -> ThrowsError LispValSource

Multiply the given numbers

numDiv :: [LispVal] -> ThrowsError LispValSource

Divide the given numbers

numAdd :: [LispVal] -> ThrowsError LispValSource

Add the given numbers

numMod :: [LispVal] -> ThrowsError LispValSource

Take the modulus of the given numbers

numRationalize :: [LispVal] -> ThrowsError LispValSource

Convert the given number to a rational

numBoolBinopGt :: [LispVal] -> ThrowsError LispValSource

Numeric greater than

numBoolBinopGte :: [LispVal] -> ThrowsError LispValSource

Numeric greater than equal

numBoolBinopLte :: [LispVal] -> ThrowsError LispValSource

Numeric less than equal

numCast :: [LispVal] -> ThrowsError LispValSource

Accept two numbers and cast one of them to the appropriate type, if necessary

numDenominator :: [LispVal] -> ThrowsError LispValSource

Take the denominator of the given number

numNumerator :: [LispVal] -> ThrowsError LispValSource

Take the numerator of the given number

numInexact2Exact :: [LispVal] -> ThrowsError LispValSource

Convert an inexact number to exact

numExact2Inexact :: [LispVal] -> ThrowsError LispValSource

Convert an exact number to inexact

num2String :: [LispVal] -> ThrowsError LispValSource

Convert a number to a string; radix is optional, defaults to base 10

unpackNum :: LispVal -> ThrowsError IntegerSource

Extract an integer from the given value, throwing a type error if the wrong type is passed.

numericBinop :: (Integer -> Integer -> Integer) -> [LispVal] -> ThrowsError LispValSource

A helper function to perform a numeric operation on two values

Floating point functions

numFloor :: [LispVal] -> ThrowsError LispValSource

Floor the given number

numCeiling :: [LispVal] -> ThrowsError LispValSource

Take the ceiling of the given number

numTruncate :: [LispVal] -> ThrowsError LispValSource

Truncate the given number

numRound :: [LispVal] -> ThrowsError LispValSource

Round the given number

numExpt :: [LispVal] -> ThrowsError LispValSource

Raise the first number to the power of the second

numSqrt :: [LispVal] -> ThrowsError LispValSource

Take the square root of the given number

numExp :: [LispVal] -> ThrowsError LispValSource

Take the exponent of the given number

numLog :: [LispVal] -> ThrowsError LispValSource

Compute the log of a given number

Trigonometric functions

Complex functions

buildComplexSource

Arguments

:: LispVal

Real part

-> LispVal

Imaginary part

-> ThrowsError LispVal

Complex number

Create a complex number

numMakePolar :: [LispVal] -> ThrowsError LispValSource

Create a complex number from its magnitude and phase (angle)

numRealPart :: [LispVal] -> ThrowsError LispValSource

Retrieve real part of a complex number

numImagPart :: [LispVal] -> ThrowsError LispValSource

Retrieve imaginary part of a complex number

numMagnitude :: [LispVal] -> ThrowsError LispValSource

The nonnegative magnitude of a complex number

numAngle :: [LispVal] -> ThrowsError LispValSource

The phase of a complex number

numMakeRectangular :: [LispVal] -> ThrowsError LispValSource

Create a complex number given its real and imaginary parts

Predicates

isComplex :: [LispVal] -> ThrowsError LispValSource

Predicate to determine if given number is complex. Keep in mind this does not just look at the types

isReal :: [LispVal] -> ThrowsError LispValSource

Predicate to determine if given number is a real. Keep in mind this does not just look at the types

isRational :: [LispVal] -> ThrowsError LispValSource

Predicate to determine if given number is a rational. Keep in mind this does not just look at the types

isInteger :: [LispVal] -> ThrowsError LispValSource

Predicate to determine if given number is an integer. Keep in mind this does not just look at the types; a floating point input value can return true, for example.

isNumber :: [LispVal] -> ThrowsError LispValSource

Predicate to determine if given value is a number

isFloatAnInteger :: LispVal -> BoolSource

A utility function to determine if given value is a floating point number representing an whole number (integer).