ops

package
v5.12.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const EarthRadius = 6371000

Variables

View Source
var Emoji = map[string]string{}/* 1870 elements not displayed */
View Source
var Entities = map[string]string{}/* 2089 elements not displayed */
View Source
var TimeZones = map[string]string{}/* 598 elements not displayed */

Functions

func AbsBigInt

func AbsBigInt(c zc.Calc)

oper abs func AbsBigInt p0:BigInt -- BigInt func AbsDecimal p0:Decimal -- Decimal func AbsFloat p0:Float -- Float func AbsRational p0:Rational -- Rational title Absolute value

desc If *p0* is less than zero, the negated value of *p0*, otherwise *p0*. end

example -6 -- -6 abs -- 6 end

func AbsComplex

func AbsComplex(c zc.Calc)

oper abs func AbsComplex p0:Complex -- Float title Distance from zero in complex plane

desc The distance of *p0* from zero in the complex plane. end

example 2+2i abs 5 round -- 2.82843 end

func AbsDecimal

func AbsDecimal(c zc.Calc)

func AbsFloat

func AbsFloat(c zc.Calc)

func AbsRational

func AbsRational(c zc.Calc)

func AcosComplex

func AcosComplex(c zc.Calc)

func AcosFloat

func AcosFloat(c zc.Calc)

oper acos func AcosFloat p0:Float -- Float title Inverse cosine

desc Inverse cosine of *p0* in radians. end

example 0.5 acos 5 round -- 1.0472 end

func AcoshComplex

func AcoshComplex(c zc.Calc)

oper acosh func AcoshComplex p0:Complex -- Complex title Inverse hyperbolic cosine

desc Inverse hyperbolic cosine of *p0* end

example 2+2i acosh 5 round -- 1.73432+0.81655i end

func AcoshFloat

func AcoshFloat(c zc.Calc)

oper acosh func AcoshFloat p0:Float -- Float title Inverse hyperbolic cosine

desc Inverse hyperbolic cosine of *p0* in radians. end

example 2 acosh 5 round -- 1.31696 end

func AddBigFloat

func AddBigFloat(c zc.Calc)

func AddBigInt

func AddBigInt(c zc.Calc)

oper add func AddBigInt p0:BigInt p1:BigInt -- BigInt func AddDecimal p0:Decimal p1:Decimal -- Decimal func AddBigFloat p0:BigFloat p1:BigFloat -- BigFloat func AddFloat p0:Float p1:Float -- Float func AddRational p0:Rational p1:Rational -- Rational func AddComplex p0:Complex p1:Complex -- Complex alias a alias + title Addition

desc Adds the value of *p1* to *p0*. end

example 6 -- 6 2 -- 6 | 2 a -- 8 end

func AddComplex

func AddComplex(c zc.Calc)

func AddDateTimeDuration

func AddDateTimeDuration(c zc.Calc)

func AddDecimal

func AddDecimal(c zc.Calc)

func AddDuration

func AddDuration(c zc.Calc)

oper add func AddDuration p0:Duration p1:Duration -- Duration func AddDurationDateTime p0:Duration p1:DateTime -- Duration func AddDateTimeDuration p0:DateTime p1:Duration -- Duration alias a alias + title Time or duration addition

desc Adds a duration and time or adds two durations. end

example c 3:30pm -- 3:30pm 2h add -- Mon Jan 2 2006 5:30:00pm -0700 MST c 2h30m -- 2h30m 45m add -- 3h 15m end

func AddDurationDateTime

func AddDurationDateTime(c zc.Calc)

func AddFloat

func AddFloat(c zc.Calc)

func AddRational

func AddRational(c zc.Calc)

func AndBigInt

func AndBigInt(c zc.Calc)

oper and func AndBigInt p0:BigInt p1:BigInt -- BigInt title Bitwise and

desc The bitwise and of `p0` and `p1` end

example 0b1100 -- 0b1100 0b1010 -- 0b1100 | 0b1010 and bin -- 0b1000 end

func AndBool

func AndBool(c zc.Calc)

oper and func AndBool p0:Bool p1:Bool -- Bool title Logical conjunction

desc The logical conjunction of *p0* and *p1*. end

example c true true and -- true c true false and -- false c false false and -- false end

func Anno

func Anno(c zc.Calc)

oper anno func Anno p0:Val anno:Str -- p0:Val alias annotate title Annotate value

desc Annotate the value of *p0* with *anno*. end

example 42 -- 42 'the answer' anno -- 42 # the answer end

func Apply

func Apply(c zc.Calc)

oper apply func Apply args:Val* fn:Str nargs:Int -- Val* title Apply a function using arguments on stack

desc Evaluates the expression in *fn* by first popping *nargs* off the stack and pushing them back as a single argument. This is useful for higher order functions, like map, where some of the arguments are from existing results found on the stack. end

example 1 2 3 4 -- 1 | 2 | 3 | 4 n -- 1 | 2 | 3 | 4 | 4 # size [swap sub] [map] 2 apply -- 3 | 2 | 1 | 0 end

func AsinComplex

func AsinComplex(c zc.Calc)

oper asin func AsinComplex p0:Complex -- Complex title Inverse sine

desc Inverse sine of *p0*. end

example 0.5+2i asin 5 round -- 0.22102+1.46572i end

func AsinFloat

func AsinFloat(c zc.Calc)

oper asin func AsinFloat p0:Float -- Float title Inverse sine

desc Inverse sine of *p0* in radians. end

example 0.5 asin 5 round -- 0.5236 end

func AsinhComplex

func AsinhComplex(c zc.Calc)

oper asinh func AsinComplex p0:Complex -- Complex title Inverse hyperbolic sine

desc Inverse hyperbolic sine of *p0*. end

example 2+2i asinh 5 round -- 0.75425+1.73432i end

func AsinhFloat

func AsinhFloat(c zc.Calc)

oper asinh func AsinhFloat p0:Float -- Float title Inverse hyperbolic sine

desc Inverse hyperbolic sine of *p0* in radians. end

example 2 asinh 5 round -- 1.44364 end

func Atan2Float

func Atan2Float(c zc.Calc)

oper atan2 func Atan2Float p0:Float p1:Float -- Float title Inverse tangent

desc Inverse tangent of *p0*\/*p1*. end

example 1 2 atan2 5 round -- 0.46365 end

func AtanComplex

func AtanComplex(c zc.Calc)

oper atan func AtanComplex p0:Complex -- Complex title Inverse tangent

desc Inverse tangent of *p0*. end

example 0.5+2i atan 5 round -- 1.42155+0.50037i end

func AtanFloat

func AtanFloat(c zc.Calc)

oper atan func AtanFloat p0:Float -- Float title Inverse tangent

desc Inverse tangent of *p0* in radians. end

example 0.5 atan 5 round -- 0.46365 end

func AtanhComplex

func AtanhComplex(c zc.Calc)

oper atanh func AtanhComplex p0:Complex -- Complex title Inverse hyperbolic tangent

desc Inverse hyperbolic tangent of *p0*. end

example 0.5+2i atanh 5 round --0.09642+1.12656i end

func AtanhFloat

func AtanhFloat(c zc.Calc)

oper atanh func AtanhFloat p0:Float -- Float title Inverse hyperbolic tangent

desc Inverse hyperbolic tangent of *p0* in radians. end

example 0.5 atanh 5 round -- 0.54931 end

func Average

func Average(c zc.Calc)

oper average func Average BigInt* -- BigInt func - Decimal* -- Decimal func - Float* -- Float func - Rational* -- Rational func - Complex* -- Complex alias avg title Average

desc The average of all items on the stack. end

example 0 100 25 75 avg -- 50 end

func Bin

func Bin(c zc.Calc)

oper bin func Bin p0:BigInt -- BigInt title Binary conversion

desc Convert the value of *p0* to a binary number. end

example 0x0f -- 0x0f bin -- 0b1111 end

func Bit

func Bit(c zc.Calc)

oper bit func Bit p0:BigInt n:Int -- Uint title Bit value

desc The value of the *n*th bit of *p0*. end

example 0b100 -- 0b100 2 bit -- 1 end

func Bits

func Bits(c zc.Calc)

oper bits func Bits p0:BigInt -- Int title Length in bits

desc The length of *p0* in bits. end

example 0b11111 -- 0b11111 bits -- 5 end

func Bytes

func Bytes(c zc.Calc)

oper bytes func Bytes p0:BigInt -- Int title Length in bytes

desc The length of *p0* in bytes. end

example 0x1ff -- 0x1ff bytes -- 2 end

func CMYKToRGB

func CMYKToRGB(calc zc.Calc)

oper cmyk-rgb func CMYKToRGB c:Uint8 m:Uint8 y:Uint8 k:Uint8 -- r:Uint8 g:Uint8 b:Uint8 title CMYK to RGB color space

desc Convert the CMYK color *c*, *m*, *y*, *k*, to the RGB color space as *r*, *b*, *g*. end

example 0 127 191 127 -- 0 | 127 | 191 | 127 cmyk-rgb -- 128 | 64 | 32 end

func CeilDecimal

func CeilDecimal(c zc.Calc)

oper ceil func NoOp p0:BigInt -- BigInt func CeilDecimal p0:Decimal -- Decimal func CeilFloat p0:Float -- Float title Ceiling

desc The nearest integer value greater than or equal to *p0*. end

example 6.12 -- 6.12 ceil -- 7 end

func CeilFloat

func CeilFloat(c zc.Calc)

func CharToCodePoint

func CharToCodePoint(c zc.Calc)

oper char-codepoint func CharToCodePoint p0:Char -- Int32 alias char-cp title Character to code point

desc Converts the character *p0* into an integer code point. end

example [°] -- ° char-cp -- 176 hex -- 0xb0 end

func Clear

func Clear(c zc.Calc)

oper clear func Clear Val* -- alias c title Clear the stack

desc Remove all items from the stack. end

example 1 -- 1 2 -- 1 | 2 clear -- end

func ClearAll

func ClearAll(c zc.Calc)

oper clear-all func ClearAll Val* -- alias ca title Clear stack and memory

desc Remove all items from the stack and any stacks stored in memory. end

example 1 -- 1 2 -- 1 | 2 store -- *stored* clear-all -- *cleared* recall -- memory empty end

func CodePointToChar

func CodePointToChar(c zc.Calc)

oper codepoint-char func CodePointToChar p0:Int32 -- Char alias cp-char title Code point to character

desc Coverts the code point *p0* to a character. end

example 0xb0 -- 0xb0 cp-char -- ° end

func Coeff

func Coeff(c zc.Calc)

oper coeff func Coeff p0:Decimal -- BigInt title Coefficient

desc The value of *p0* without the decimal point. end

example 12.345 coeff -- 12345 end

func ColorSample

func ColorSample(calc zc.Calc)

oper color-sample func ColorSample r:Uint8 g:Uint8 b:Uint8 -- Str title Render a sample of a color

desc Render five spaces with a background color of *r*, *g*, and *b*. The terminal in use must be able to support 24-bit ANSI color codes. end

func Complex

func Complex(c zc.Calc)

oper complex func Complex r:Float i:Float -- Complex title Complex from real and imaginary

desc A complex number from a real *r* and an imaginary *i* number. end

example 6 -- 6 12 -- 6 | 12 complex -- 6+12i end

func Conj

func Conj(c zc.Calc)

oper conj func Conj p0:Complex -- Complex title Complex conjugate

desc The complex conjugate of *p0* end

example 5+3i conj -- 5-3i end

func CosComplex

func CosComplex(c zc.Calc)

oper cos func CosComplex p0:Complex -- Complex title Cosine

desc Cosine of *p0*. end

example 2+2i cos 5 round -- -1.56563-3.29789i end

func CosFloat

func CosFloat(c zc.Calc)

oper cos func CosFloat p0:Float -- Float title Cosine

desc Cosine of *p0* in radians. end

example 2 cos 5 round -- -0.41615 end

func CoshComplex

func CoshComplex(c zc.Calc)

oper cosh func CoshComplex p0:Complex -- Complex title Hyperbolic cosine

desc Hyperbolic cosine of *p0*. end

example 2+2i cosh 5 round -- -1.56563+3.29789i end

func CoshFloat

func CoshFloat(c zc.Calc)

oper cosh func CoshFloat p0:Float -- Float title Hyperbolic cosine

desc Hyperbolic cosine of *p0* in radians. end

example 2 cosh 5 round -- 3.7622 end

func CotComplex

func CotComplex(c zc.Calc)

oper cot func CotComplex p0:Complex -- Complex title Cotangent

desc Cotangent of *p0*. end

example 2+3i cot 5 round -- -0.00374-0.99676i end

func DM

func DM(c zc.Calc)

oper deg-min func DM p0:DMS -- DMS alias dm title Angle in degrees and minutes

desc Reformat the angle *p0* to degrees and minutes example 10.1234 dm -- 10° 7.404000000000011′ end

func DMRound

func DMRound(c zc.Calc)

oper deg-min-round func DMRound p0:DMS n:Int -- DMS alias dmr title Rounded angle in degrees and minutes

desc Reformat the angle *p0* to degrees and minutes and round the minutes to *n* places. end

example 12.57611 3 dmr -- 12° 34.567′ end

func DMS

func DMS(c zc.Calc)

oper deg-min-sec func DMS p0:DMS -- DMS alias dms title Angle in degrees and minutes

desc Reformat the angle *p0* to degrees, minutes, and seconds. end

example -76.856944 dms -- -76° 51′ 24.9984″ end

func DMSIs added in v5.12.0

func DMSIs(c zc.Calc)

oper dms? func DMSIs p0:Str -- Bool alias dec-min-sec? title Checks value can be parsed as degree, minutes, seconds

desc Returns `true` if the value *p0* can be parsed as an angle with degrees, minutes, and seconds. end

example c [10° 30′ 45″] dms? -- true c [10 30 45 ] dms? -- false end

func DMSRound

func DMSRound(c zc.Calc)

oper deg-min-sec-round func DMSRound p0:DMS n:Int -- DMS alias dmsr title Rounded angle in degrees, minutes, seconds

desc Reformat the angle *p0* to degrees, minutes, and seconds, and round the seconds to *n* places. end

example -76.856944 0 dmsr -- -76° 51′ 25″ end

func Date

func Date(c zc.Calc)

oper date func Date p0:DateTime -- Date title Formats to a common date layout

desc Formats date/time *p0* to a common date layout. Time information, if any, is removed. end

example '2006-01-02T15:04:05 UTC -- 2006-01-02T15:04:05 UTC date -- Mon Jan 2 2006 end

func DateTime

func DateTime(c zc.Calc)

oper datetime func DateTime p0:DateTime -- DateTime alias dt title Formats to a common date/time layout

desc Formats a date/time to a common layout. end

example '2006-01-02T15:04:05 UTC -- 2006-01-02T15:04:05 UTC datetime -- Mon Jan 2 2006 3:04:05pm UTC end

func DateTimeIs added in v5.12.0

func DateTimeIs(c zc.Calc)

oper datetime? func DateTimeIs p0:Str -- Bool alias dt? title Checks value can be parsed as a `DateTime`

desc Returns `true` if the value *p0* can be parsed as a DateTime. end

example c [2 May 2023] datetime? -- true c [2 Nay 2023] datetime? -- false end

func DayYear

func DayYear(c zc.Calc)

oper day-year func DayYear p0:DateTime -- Int alias doy title Day of year

desc Day of year for a given date *p0*. end

example 2006-03-15 -- 2006-03-15 day-year -- 74 end

func Dec

func Dec(c zc.Calc)

oper dec func Dec p0:Decimal -- Decimal func DecFloat p0:Float -- Decimal title Decimal number

desc Pops *p0* from the stack and formats it as a `Decimal`. end

example 1e3 dec -- 1000 end

func DecBigInt

func DecBigInt(c zc.Calc)

oper dec func DecBigInt p0:BigInt -- BigInt title Decimal conversion

desc Convert the value of *p0* to a decimal number. end

example 0xf -- 0xf dec -- 15 end

func DecDMS

func DecDMS(c zc.Calc)

oper dec func DecDMS p0:DMS -- Decimal title DMS angle to decimal degrees

desc Convert the DMS angle *p0* to decimal degrees. end

example 10d7m24.24s dec -- 10.1234 end

func DecFloat

func DecFloat(c zc.Calc)

func DecRational

func DecRational(c zc.Calc)

oper dec func DecRational p0:Rational -- Decimal title Decimal number

desc Pops *p0* from the stack and formats it as a `Decimal`. end

example 1/2 dec -- 0.5 end

func Denom

func Denom(c zc.Calc)

oper denom func Denom p0:Rational -- BigInt title Denominator

desc The denominator of rational number *p0*. end

example 2/3 denom -- 3 end

func DivBigFloat

func DivBigFloat(c zc.Calc)

func DivComplex

func DivComplex(c zc.Calc)

func DivDecimal

func DivDecimal(c zc.Calc)

oper div func DivDecimal p0:Decimal p1:Decimal -- Decimal func DivBigFloat p0:BigFloat p1:BigFloat -- BigFloat func DivFloat p0:Float p1:Float -- Float func DivRational p0:Rational p1:Rational -- Rational func DivComplex p0:Complex p1:Complex -- Complex alias d alias / title Division

desc Divides the value of *p0* by *p1*. If *p1* is zero, a 'division by zero' error is raised. end

example 6 -- 6 2 -- 6 | 2 d -- 3 end

func DivFloat

func DivFloat(c zc.Calc)

func DivRational

func DivRational(c zc.Calc)

func DivRemBigInt added in v5.8.0

func DivRemBigInt(c zc.Calc)

func DivRemDec added in v5.8.0

func DivRemDec(c zc.Calc)

oper div-rem func DivRemDec p0:Decimal p1:Decimal p:Int32 -- r:Decimal q:Decimal func DivRemBigInt p0:BigInt p1:BigInt -- r:Decimal q:Decimal alias dr title Division with remainder

desc Divides *p0* by *p1* with the precision *p* and returns the quotient *q* and remainder *r*. The following shows how to divide one dollar with three people which gives a quotient of $0.33 and a remainder of one cent. end

example 1.00 3 2 div-rem -- 0.01 # remainder | 0.33 end

func Down

func Down(c zc.Calc)

oper down func Down Val* -- Val* alias dn title Rotate stack downward

desc Rotate items on the stack by moving downward.

In the interactive calculator, the top of the stack is towards the bottom of the terminal so downward means seeing all items moves toward the bottom. The top of the stack wraps around to be the bottom of the stack. end

example 1 2 3 -- 1 | 2 | 3 down -- 3 | 1 | 2 down -- 2 | 3 | 1 end

func Drop

func Drop(c zc.Calc)

oper drop func Drop Val -- title Drop top item from stack

desc Remove the top item from the stack. end

example 1 -- 1 2 -- 1 | 2 drop -- 1 end

func Dup

func Dup(c zc.Calc)

oper dup func Dup p0:Val -- p0:Val p0:Val title Duplicate top stack item

desc Duplicate the top item on the stack. end

example 1 -- 1 dup -- 1 | 1 end

func EarthRadiusFn

func EarthRadiusFn(c zc.Calc)

oper earth-radius func EarthRadiusFn -- Int title Average radius of the Earth

desc The volumetric mean radius of the Earth in meters.

Source: https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html end

example earth-radius -- 6371000 # m end

func EqBigInt

func EqBigInt(c zc.Calc)

oper eq func EqBigInt p0:BigInt p1:BigInt -- BigInt func EqDecimal p0:Decimal p1:Decimal -- Decimal func EqFloat p0:Float p1:Float -- Float func EqRational p0:Rational p1:Rational -- Rational func EqComplex p0:Complex p1:Complex -- Complex func Is p0:Str p1:Str -- Str title Equal

desc `true` if *p0* and *p1* are equal, otherwise `false`. end

example c 1234.56 1,234.56 eq -- true c 1234.56 1234.56000 eq -- true c 1234.56 $1,234.56 eq -- true c 1234.56 +1,234.56 eq -- true end

func EqComplex

func EqComplex(c zc.Calc)

func EqDecimal

func EqDecimal(c zc.Calc)

func EqFloat

func EqFloat(c zc.Calc)

func EqRational

func EqRational(c zc.Calc)

func Eval

func Eval(c zc.Calc)

oper eval func Eval expr:Str -- Val* title Evaluate top of stack

desc Evaluate *expr* as if it was input to the calculator. end

example [1 2 add -- 1 2 add eval -- 3 end

func ExpComplex

func ExpComplex(c zc.Calc)

oper exp func ExpComplex p0:Complex -- Complex title Natural exponential

desc Natural exponential of *p0*. end

example 2+2i exp 5 round -- -3.07493+6.71885i end

func ExpFloat

func ExpFloat(c zc.Calc)

oper exp func ExpFloat p0:Float -- Float title Natural exponential

desc Natural exponential of *p0*. end

example 2 exp 5 round -- 7.38906 end

func Factorial

func Factorial(c zc.Calc)

oper factorial func Factorial n:BigInt -- BigInt alias fact title Factorial

desc The product of all positive integers less than or equal to *n*. If *n* is negative, an invalid argument error is displayed. end

example c 3 fact -- 6 c 10 fact -- 3628800 end

func Fibonacci added in v5.5.0

func Fibonacci(c zc.Calc)

oper fibonacci func Fibonacci n:Int -- BigInt* alias fib title Fibonacci sequence

desc Calculates the *n*th element in the Fibonacci sequence. The value of *n* must be equal to or greater than zero. end

example 1 5 seq /fib map -- 1 | 1 | 2 | 3 | 5 end

func Filter

func Filter(c zc.Calc)

oper filter func Filter Val* expr:Str -- Val* title Filter items in the stack

desc Filter the stack by keeping items that are true when evaluated by expression *expr*. end

example 1 2 3 4 5 6 -- 1 | 2 | 3 | 4 | 5 | 6 [2 mod 0 eq] filter -- 2 | 4 | 6 end

func FloorDecimal

func FloorDecimal(c zc.Calc)

oper floor func NoOp p0:BigInt -- BigInt func FloorDecimal p0:Decimal -- Decimal func FloorFloat p0:Float -- Float title Floor

desc The nearest integer value less than or equal to *p0*. end

example 6.12 -- 6.12 floor -- 6 end

func FloorFloat

func FloorFloat(c zc.Calc)

func Fold

func Fold(c zc.Calc)

oper fold func Fold Val* expr:Str -- Val alias reduce title Reduce items to a single value

desc Reduce the stack to a single value using the expression *expr*. An 'invalid function' error is raised if *expr* does not reduce. end

example 1 2 3 4 5 -- 1 | 2 | 3 | 4 | 5 [add] fold -- 15 end

func Get

func Get(c zc.Calc)

oper get func Get Val* name:Str -- Val* Val* title Get a named stack from memory

func GtBigInt

func GtBigInt(c zc.Calc)

oper gt func GtBigInt p0:BigInt p1:BigInt -- Bool func GtDecimal p0:Decimal p1:Decimal -- Bool func GtRational p0:Rational p1:Rational -- Bool func GtFloat p0:Float p1:Float -- Bool func GtStr p0:Str p1:Str -- Bool alias greater-than title Greater than

desc `true` if *p0* is greater than *p1*, otherwise `false`. end

example c 1 0 gt -- true c 0 0 gt -- false c -1 0 gt -- false end

func GtDecimal

func GtDecimal(c zc.Calc)

func GtFloat

func GtFloat(c zc.Calc)

func GtRational

func GtRational(c zc.Calc)

func GtStr

func GtStr(c zc.Calc)

func GteBigInt

func GteBigInt(c zc.Calc)

oper gte func GteBigInt p0:BigInt p1:BigInt -- Bool func GteDecimal p0:Decimal p1:Decimal -- Bool func GteRational p0:Rational p1:Rational -- Bool func GteFloat p0:Float p1:Float -- Bool func GteStr p0:Str p1:Str -- Bool alias greater-than-or-equal title Greater than or equal

desc `true` if *p0* is greater than or equal *p1*, otherwise `false`. end

example c 1 0 gte -- true c 0 0 gte -- true c -1 0 gte -- false end

func GteDecimal

func GteDecimal(c zc.Calc)

func GteFloat

func GteFloat(c zc.Calc)

func GteRational

func GteRational(c zc.Calc)

func GteStr

func GteStr(c zc.Calc)

func HSLToRGB

func HSLToRGB(calc zc.Calc)

oper hsl-rgb func HSLToRGB h:Float s:Float l:Float -- r:Uint8 g:Uint8 b:Uint8 title HSL to RGB color space

desc Convert the HSL color *h*, *s*, *l* to the RGB color space as *r*, *g*, *b*. end

example 20 0.6 0.314 -- 20 | 0.6 | 0.314 hsl-rgb -- 128 | 64 | 32 end

func Haversine

func Haversine(c zc.Calc)

oper haversine func Haversine lat0:DMS lon0:DMS lat1:DMS lon1:DMS -- Float title Great circle distance between two points

desc Calculates the great circle distance between (*lat0*, *lon0*) and (*lat1*, *lon1*) using the haversine formula.

Source: https://community.esri.com/t5/coordinate-reference-systems-blog/distance-on-a-sphere-the-haversine-formula/ba-p/902128 end

The following shows the great circle distance between Washington, DC and New York, NY:

example 38°54′17″N 77°00′59″W -- 38°54′17″N | 77°00′59″W 40°42′46″N 74°00′22″W -- 38°54′17″N | 77°00′59″W | 40°42′46″N | 74°00′22″W haversine 2 round -- 326364.76 # m m-km 2 round -- 326.36 # km km-mi 2 round -- 202.79 # mi end

func HexBigInt

func HexBigInt(c zc.Calc)

oper hex func HexBigInt p0:BigInt -- BigInt title Hexadecimal conversion

desc Convert the value of *p0* to a hexadecimal number. end

example 0b1111 -- 0b1111 hex -- 0xf end

func Hours

func Hours(c zc.Calc)

oper hours func Hours p0:Duration -- Float title Hours in duration

desc Converts the duration *p0* into hours. end

example 10h20m30s -- 10h20m30s hours 2 round -- 10.34 end

func Imag

func Imag(c zc.Calc)

oper imag func Imag p0:Complex -- Float title Imaginary number from complex

desc The imaginary number part of complex number *p0* end

example 3+4i imag -- 4 end

func Int

func Int(c zc.Calc)

func Inv

func Inv(c zc.Calc)

oper inv func Inv p0:Rational -- Rational title Inverse

desc Returns the inverse which is 1/*p0*. end

example 1/2 inv -- 2 end

func Is

func Is(c zc.Calc)

oper is func Is p0:Str p1:Str -- Bool title Byte equality

desc `true` if *p0* and *p1* are the same, byte by byte. end

example c 1.2 1.20 is -- false c 1.2 1.2 is -- true end

func Join

func Join(c zc.Calc)

oper join func Join Val* sep:Str -- Str title Join stack elements

desc Join all stack elements into a single string separated by *sep*. end

example 128 8 74 2 -- 128 | 8 | 74 | 2 '.' join -- 128.8.74.2 end

func JoinBits added in v5.5.0

func JoinBits(c zc.Calc)

oper join-bits func JoinBits BigInt* n:Int -- BigInt* alias joinb title Join a binary number by bit width

desc Join all numbers in the stack, which contain *n* bits into a single number. If a value on the stack contains more than *n* bits, an error is raised. end

example c 0xa 0xb 0xc 0xd 4 joinb hex -- 0xabcd c 0xab 0xcd 8 joinb hex -- 0xabcd end

func Left

func Left(c zc.Calc)

oper left func Left p0:Str n:Int -- Str title Left substring

desc Substring of *s* from the left.

If *n* is positive, *m* characters are taken from the left. If *n* is negative, characters are taken from the left until there are *n* characters remaining. If *n* is zero, *s* is returned without change.

If the absolute value of *n* is greater then then length of *s*, an 'illegal arguments' error is raised. end

example 'abcdef -- abcdef 4 left -- abcd -1 left -- abc end

func Len

func Len(c zc.Calc)

oper len func Len p0:Str -- Int title Length of text in characters

desc Length of text in characters. end

example c 'abcd' len -- 4 c '🥇🥈🥉👏' len -- 4 end

func LocalZone

func LocalZone(c zc.Calc)

oper local-zone func LocalZone p0:Str -- title Sets the local time zone

desc Sets the local time zone to *p0*. end

exammple now time -- 3:04:05pm -0700 MST c [est] local-zone -- *local time zone is now 'EST'* now time -- 5:04:05pm -0500 EST c Asia/Jakarta local-zone -- *local time zone is now 'Asia/Jakarta'* now time -- 5:04:05am +0700 end

func LocalZoneGet

func LocalZoneGet(c zc.Calc)

oper local-zone= func LocalZoneGet -- Str title Gets the local time zone

desc Gets the local time zone. end

example local-zone= -- MST end

func Log10Complex

func Log10Complex(c zc.Calc)

oper log10 func Log10Complex p0:Complex -- Complex title Decimal logarithm

desc Decimal logarithm of *p0*. end

example 50+20i log10 5 round -- 1.7312+0.16525i end

func Log10Float

func Log10Float(c zc.Calc)

oper log10 func Log10Float p0:Float -- Float title Decimal logarithm

desc Decimal logarithm of *p0*. end

example 50 log10 5 round -- 1.69897 end

func Log2Float

func Log2Float(c zc.Calc)

oper log2 func Log2Float p0:Float -- Float title Binary logarithm

desc Binary logarithm of *p0*. end

example 250 log2 5 round -- 7.96578 end

func LogComplex

func LogComplex(c zc.Calc)

oper log func LogComplex p0:Complex -- Complex title Natural logarithm

desc Natural logarithm of *p0*. end

example 8+2i log 5 round -- 2.10975+0.24498i end

func LogFloat

func LogFloat(c zc.Calc)

oper log func LogFloat p0:Float -- Float title Natural logarithm

desc Natural logarithm of *p0*. end

example 8 log 5 round -- 2.07944 end

func Lower

func Lower(c zc.Calc)

oper lower func Lower p0:Str -- Str title Lowercase

desc Converts the string *p0* to lowercase. end

example 'AbCd -- AbCd lower -- abcd end

func Lsh

func Lsh(c zc.Calc)

oper lsh func Lsh p0:BigInt n:Uint -- BigInt alias left-shift title Left shift bits

desc Shifts all bits in *p0* to the left by *n*. end

example 0b10 -- 0b10 2 lsh bin -- 0b1000 end

func LtBigInt

func LtBigInt(c zc.Calc)

oper lt func LtBigInt p0:BigInt p1:BigInt -- Bool func LtDecimal p0:Decimal p1:Decimal -- Bool func LtRational p0:Rational p1:Rational -- Bool func LtFloat p0:Float p1:Float -- Bool func LtStr p0:Str p1:Str -- Bool alias less-than title Less than

desc `true` if *p0* is less than *p1*, otherwise `false`. end

example c 1 0 lt -- false c 0 0 lt -- false c -1 0 lt -- true end

func LtDecimal

func LtDecimal(c zc.Calc)

func LtFloat

func LtFloat(c zc.Calc)

func LtRational

func LtRational(c zc.Calc)

func LtStr

func LtStr(c zc.Calc)

func LteBigInt

func LteBigInt(c zc.Calc)

oper lte func LteBigInt p0:BigInt p1:BigInt -- Bool func LteDecimal p0:Decimal p1:Decimal -- Bool func LteRational p0:Rational p1:Rational -- Bool func LteFloat p0:Float p1:Float -- Bool func LteStr p0:Str p1:Str -- Bool alias less-than-or-equal title Less than or equal

desc `true` if *p0* is less than or equal to *p1*, otherwise `false`. end

example c 1 0 lte -- false c 0 0 lte -- true c -1 0 lte -- true end

func LteDecimal

func LteDecimal(c zc.Calc)

func LteFloat

func LteFloat(c zc.Calc)

func LteRational

func LteRational(c zc.Calc)

func LteStr

func LteStr(c zc.Calc)

func Map

func Map(c zc.Calc)

oper map func Map Val* expr:Str -- Val* title Apply a function to each item on the stack

desc Apply expression *expr* to each value in the stack. end

example 1 2 3 4 5 -- 1 | 2 | 3 | 4 | 5 [2 mul] map -- 2 | 4 | 6 | 8 | 10 end

func Md5 added in v5.5.0

func Md5(c zc.Calc)

oper md5 func Md5 p0:Str -- Str title MD5 hash function

desc Hash *p0* with the MD5 function. end

example 'Behind the tree! -- Behind the tree! md5 -- 0xbbce0fb98a6a1b308e589d1408968ac2 end

func Minutes

func Minutes(c zc.Calc)

oper minutes func Minutes p0:Duration -- Float title Minutes in duration

desc Converts the duration *p0* into minutes. end

example 10h20m30s -- 10h20m30s minutes 2 round -- 620.5 end

func MinutesDMS

func MinutesDMS(c zc.Calc)

oper minutes func MinutesDMS p0:DMS -- Decimal title Angle in minutes

desc Converts the angle *p0* to minutes. end

example 10d30m minutes -- 630 end

func ModBigInt

func ModBigInt(c zc.Calc)

oper mod func ModBigInt p0:BigInt p1:BigInt -- BigInt func ModDecimal p0:Decimal p1:Decimal -- Decimal func ModFloat p0:Float p1:Float -- Float title Modulus

desc The modulus when *p0* is divided by *p1*. If *p1* is zero, a 'division by zero' error is raised. end

example -7 2 mod -- 1 end

func ModDecimal

func ModDecimal(c zc.Calc)

func ModFloat

func ModFloat(c zc.Calc)

func MulBigFloat

func MulBigFloat(c zc.Calc)

func MulBigInt

func MulBigInt(c zc.Calc)

oper mul func MulBigInt p0:BigInt p1:BigInt -- BigInt func MulDecimal p0:Decimal p1:Decimal -- Decimal func MulBigFloat p0:BigFloat p1:BigFloat -- BigFloat func MulFloat p0:Float p1:Float -- Float func MulRational p0:Rational p1:Rational -- Rational func MulComplex p0:Complex p1:Complex -- Complex alias m alias * title Multiplication

desc Multiplies *p0* by *p1*. end

example 6 -- 6 2 -- 6 | 2 m -- 12 end

func MulComplex

func MulComplex(c zc.Calc)

func MulDecimal

func MulDecimal(c zc.Calc)

func MulFloat

func MulFloat(c zc.Calc)

func MulRational

func MulRational(c zc.Calc)

func NegBigFloat

func NegBigFloat(c zc.Calc)

func NegBigInt

func NegBigInt(c zc.Calc)

oper neg func NegBigInt p0:BigInt -- BigInt func NegDecimal p0:Decimal -- Decimal func NegBigFloat p0:BigFloat -- BigFloat func NegFloat p0:Float -- Float func NegRational p0:Rational -- Rational title Negation

desc Changes the sign of `p0`. end

example -6 -- -6 neg -- 6 neg -- -6 end

func NegDecimal

func NegDecimal(c zc.Calc)

func NegFloat

func NegFloat(c zc.Calc)

func NegRational

func NegRational(c zc.Calc)

func NoAnno

func NoAnno(c zc.Calc)

oper no-anno func NoAnno p0:Val -- p0:Val alias noa alias no-annotation title Remove annotation

desc Remove the annotation, if any, from *p0*. end

example 42 -- 42 'the answer' anno -- 42 # the answer noa -- 42 end

func NotBigInt

func NotBigInt(c zc.Calc)

oper not func NotBigInt p0:BigInt -- BigInt title Bitwise not

desc The bitwise not of *p0*. end

example 0b101 -- 0b101 not bin -- -0b110 end

func NotBool

func NotBool(c zc.Calc)

oper not func NotBool Bool -- Bool title Negation

desc If `true`, returns `false`, otherwise returns `true`. end

example true not -- false not -- true end

func Now

func Now(c zc.Calc)

oper now func Now -- DateTime title Current date and time

desc The current date and time. If `now-set` has been called, that date and time will be returned instead. end

example now -- Mon Jan 2 2006 3:04:05pm -0700 MST end

func NowRestore

func NowRestore(c zc.Calc)

oper now- func NowRestore -- title Cancel now override

desc Cancel override of the value returned by now. end

func NowSet

func NowSet(c zc.Calc)

oper now= func NowSet p0:DateTime -- title Override now value

desc Override the value returned by `now`. Useful for to mocking current time while testing. end

example 'Nov 5 1955 01:22 -- Nov 5 1955 01:22 now= -- *now set to 'Sat Nov 5 1955 1:22:00am -0700 MST'* now -- Sat Nov 5 1955 1:22:00am -0700 MST end

func Num

func Num(c zc.Calc)

oper num func Num p0:Rational -- BigInt title Numerator

desc The numerator of rational number *p0*. end

example 2/3 num -- 2 end

func Oct

func Oct(c zc.Calc)

oper oct func Oct p0:BigInt -- BigInt title Octal conversion

desc Convert the value of *p0* to an octal number. end

example 0b1111 -- 0b1111 oct -- 0o17 end

func OrBigInt

func OrBigInt(c zc.Calc)

oper or func OrBigInt p0:BigInt p1:BigInt -- BigInt title Bitwise or

desc The bitwise or of *p0* and *p1*. end

example 0b1100 -- 0b1100 0b1010 -- 0b1100 | 0b1010 or bin -- 0b1110 end

func OrBool

func OrBool(c zc.Calc)

oper or func OrBool p0:Bool p1:Bool -- Bool title Logical disjunction

desc The logical disjunction of *p0* and *p1*. end

example c true true or -- true c true false or -- true c false false or -- false end

func PhaseComplex

func PhaseComplex(c zc.Calc)

func PolarComplex

func PolarComplex(c zc.Calc)

oper polar func PolarComplex p0:Complex -- r:Float θ:Float title Complex to polar

desc The absolute value *r* and phase *θ* of *p0*. end

example 2i polar pi div 1 round -- 2 | 0.5 end

func PowBigInt

func PowBigInt(c zc.Calc)

oper pow func PowBigInt p0:BigInt p1:BigInt -- BigInt func PowFloat p0:Float p1:Float -- Float func PowComplex p0:Complex p1:Complex -- Complex alias ** alias ^ title Exponentiation

desc Raises *p0* to the power of *p1*. end

example 6 -- 6 2 -- 6 | 2 pow -- 36 end

func PowComplex

func PowComplex(c zc.Calc)

func PowFloat

func PowFloat(c zc.Calc)

func Proj

func Proj(c zc.Calc)

oper proj func Proj p0:Float p1:Float s:Str t:Str -- Float Float title Transform coordinate

desc Transform coordinate (*p0*, *p1*) in coordinate system *s* to a coordinate in system *t*. The order of the coordinates is defined by the coordinate system and it may be (lat, lon) or (x, y). end

example 39.203611 -76.856944 -- 39.203611 | -76.856944 epsg.wgs-84 18n epsg.utm -- 39.203611 | -76.856944 | EPSG:4326 | EPSG:32618 proj -- 339660.12559342897 | 4.341014551927999e06 end

func RGBToCMYK

func RGBToCMYK(calc zc.Calc)

oper rgb-cmyk func RGBToCMYK r:Uint8 g:Uint8 b:Uint8 -- c:Uint8 m:Uint8 y:Uint8 k:Uint8 title RGB to CMYK color space

desc Convert the RGB color *r*, *b*, *g* to the CMYK color space as *c*, *m*, *y*, *k*. end

example 128 64 32 -- 128 | 64 | 32 rgb-cmyk -- 0 | 127 | 191 | 127 end

func RGBToHSL

func RGBToHSL(calc zc.Calc)

func Rand

func Rand(c zc.Calc)

oper rand func Rand -- Float title Random float

desc Random number between 0 and 1. end

example 0 rand-seed -- *seed set to 0* rand -- 0.9451961492941164 end

func RandChoice

func RandChoice(c zc.Calc)

oper rand-choice func RandChoice ... a0:Val ... -- a0:Val title Randomly select item on stack

desc Randomly select an item on the stack. end

example 2 rand-seed -- *seed set to 2* 1 2 3 4 5 6 -- 1 | 2 | 3 | 4 | 5 | 6 rand-choice -- 5 end

func RandInt

func RandInt(c zc.Calc)

oper rand-int func RandInt n:Int -- Int title Random integer

desc Random integer between 1 and *n*. end

example 0 rand-seed -- *seed set to 0* 10 rand-int -- 5 end

func RandSeed

func RandSeed(c zc.Calc)

oper rand-seed func RandSeed seed:Int64 -- title Set the random number seed

desc Sets the random number *seed*. end

example 1 rand-seed -- *seed set to 1* 10 rand-int -- 2 end

func RandSeedGet

func RandSeedGet(c zc.Calc)

oper rand-seed= func RandSeedGet -- Int64 title Get the random number seed

desc Gets the random number seed. end

example 3 rand-seed -- *seed set to 3* rand-seed= -- 3 end

func RationalBigInt

func RationalBigInt(c zc.Calc)

func RationalFloat

func RationalFloat(c zc.Calc)

func RationalIs added in v5.12.0

func RationalIs(c zc.Calc)

oper rational? func RationalIs p0:Str -- Bool title Checks value can be parsed as a rational

desc Returns `true` if the value *p0* can be parsed as a Rational. end

example c 1/2 rational? -- true c 1+2i rational? -- false end

func Real

func Real(c zc.Calc)

oper real func Real p0:Complex -- Float title Real number from complex

desc The real number part of complex number *p0* end

example 3+4i real -- 3 end

func Recall

func Recall(c zc.Calc)

oper recall func Recall Val* -- Val* Val* alias re title Recall stack from memory

desc Recall a stack from memory. The recalled stack is placed before an existing items on the current stack. Memory is also a stack so that multiple stacks can be stored at one time. end

example 1 2 3 4 store average -- 2.5 recall -- 1 | 2 | 3 | 4 | 2.5 end

func RectComplex

func RectComplex(c zc.Calc)

oper rect func RectComplex r:Float θ:Float -- Complex title Polar to complex

desc The complex number with polar coordinates *r* and *θ*. end

example 2 0.5 pi mul rect imag -- 2 end

func RemBigInt

func RemBigInt(c zc.Calc)

oper rem func RemBigInt p0:BigInt p1:BigInt -- BigInt func RemFloat p0:Float p1:Float -- Float title Remainder

desc The remainder when *p0* is divided by *p1*. If *p1* is zero, a 'division by zero' error is raised. end

example -7 -- -7 2 -- -7 | 2 rem -- -1 end

func RemFloat

func RemFloat(c zc.Calc)

func Repeat

func Repeat(c zc.Calc)

oper repeat func Repeat expr:Val n:Int -- Val* title Repeat the execution of a function

desc Repeat execution of expression *expr* for *n* times. end

example 1 -- 1 [2 mul] 8 repeat -- 256 end

func Reverse

func Reverse(c zc.Calc)

oper reverse func Reverse Val* -- Val* alias rev title Reverse stack

desc Reverses the elements on the stack. end

example 1 2 3 4 5 -- 1 | 2 | 3 | 4 | 5 reverse -- 5 | 4 | 3 | 2 | 1 end

func Right(c zc.Calc)

oper right func Right p0:Str n:Int -- Str title Right substring

desc Substring of *p0* from the right.

If *n* is positive, *n* characters are taken from the right. If *n* is negative, characters are taken from the right until there are *n* characters remaining. If *n* is zero, *s* is returned without change.

If the absolute value of *n* is greater then then length of *s*, an 'illegal arguments' error is raised. end

example 'abcdef -- abcdef 4 right -- cdef -1 right -- def end

func Roll

func Roll(c zc.Calc)

oper roll func Roll dice:Str -- Int* title Dice roller

desc Rolls dice as specified by *dice* in standard dice notation. The argument *dice* may start with the number of dice to roll, followed by the literal character `d`, and then the number of faces found on each die. For example, use `3d6` to roll three six sided dice. end

example 99 rand-seed -- *seed set to 99* 3d6 roll -- 6 | 2 | 1 sum -- 9 end

func Rot13

func Rot13(c zc.Calc)

oper rotate-13 func Rot13 p0:Str -- Str alias rot13 title Rotate characters by 13

desc Rotate all characters in string *p0* by 13. end

example 'Behind the tree! -- Behind the tree! rot13 -- Oruvaq gur gerr! rot13 -- Behind the tree! end

func RoundComplex

func RoundComplex(c zc.Calc)

oper round func RoundComplex p0:Complex n:Int -- Complex alias r title Round to a given precision

desc Rounds the real and imaginary numbers of *p0* to *n* digits using the half up rounding mode. end

example 1.047197551196598+5.948293i 3 round -- 1.047+5.948i end

func RoundDecimal

func RoundDecimal(c zc.Calc)

oper round func RoundDecimal d:Decimal n:Int -- Decimal func RoundFloat d:Float n:Int -- Float alias r title Round to a given precision

desc Rounds the number *n* to *d* digits using the current rounding mode. end

example 2 3 div -- 0.6666666666666666666 2 round -- 0.67 end

func RoundFloat

func RoundFloat(c zc.Calc)

func RoundingMode

func RoundingMode(c zc.Calc)

oper rounding-mode func RoundingMode -- Str title Set method to use in rounding

desc Sets the mode to be used when rounding. Valid modes are:

- `half-up` - `ceil` - `down` - `floor` - `half-even` - `up`

end

example 1.01 0.05 mul -- 0.0505 2 round -- 0.05 'up' rounding-mode -- *rounding-mode set to 'up'* c 1.01 0.05 mul -- 0.0505 2 round -- 0.06 end

func RoundingModeGet

func RoundingModeGet(c zc.Calc)

oper rounding-mode= func RoundingModeGet -- Str title Method to use in rounding

desc Gets the current rounding mode end

example rounding-mode= -- half-up end

func Rsh

func Rsh(c zc.Calc)

oper rsh func Rsh p0:BigInt n:Uint -- BigInt alias right-shift title Right shift bits

desc Shifts all bits in *p0* to the right by *n*. end

example 0b1000 -- 0b1000 2 rsh bin -- 0b10 end

func ScientificNotation

func ScientificNotation(c zc.Calc)

oper scientific-notation func ScientificNotation p0:Float -- Float func ScientificNotationBigInt p0:BigInt -- Float alias sn title Scientific notation

desc Formats the value *p0* using scientific notation. end

example 1234 sn -- 1.234e03 end

func ScientificNotationBigInt

func ScientificNotationBigInt(c zc.Calc)

func Seconds

func Seconds(c zc.Calc)

oper seconds func Seconds p0:Duration -- Float title Seconds in duration

desc Converts the duration *p0* into seconds. end

example 10h20m30s -- 10h20m30s seconds -- 37230 end

func SecondsDMS

func SecondsDMS(c zc.Calc)

oper seconds func SecondsDMS p0:DMS -- Decimal title Angle in seconds

desc Converts the angle *p0* to seconds. end

example 10d30m seconds -- 37800 end

func Sequence added in v5.5.0

func Sequence(c zc.Calc)

oper sequence func Sequence p0:BigInt p1:BigInt -- BigInt* alias seq title Sequence of integers

desc Adds the integers from *p0* to *p1* to the stack. If *p0* is greater than *p1*, the list of integers is in decreasing order end

example 4 8 seq -- 4 | 5 | 6 | 7 | 8 c 8 4 seq -- 8 | 7 | 6 | 5 | 4 end

func Set

func Set(c zc.Calc)

oper set func Set Val* name:Str -- title Place a named stack to memory

func Sha1 added in v5.5.0

func Sha1(c zc.Calc)

oper sha1 func Sha1 p0:Str -- Str title SHA-1 hash function

desc Hash *p0* with the SHA-1 function. end

example 'Behind the tree! -- Behind the tree! sha1 -- 0xda6e7f530a9b42a679944f0c9fc0f86ae5534450 end

func Sha1Hmac added in v5.5.0

func Sha1Hmac(c zc.Calc)

oper sha1hmac func Sha1Hmac p0:Str key:Str -- Str title SHA-1 keyed hash function

desc Hash *p0* with *key* using the SHA-1 function end

example 'Behind the tree!' /swordfish -- Behind the tree! | swordfish sha1hmac -- 0x75859001097e8ad6907a879d340170ef571c8e5c end

func Sha224 added in v5.5.0

func Sha224(c zc.Calc)

oper sha224 func Sha224 p0:Str -- Str title SHA-224 hash function

desc Hash *p0* with the SHA-224 function. end

example 'Behind the tree! -- Behind the tree! sha224 -- 0x15eac2f886e0e09a44ce08da58f3386b707885150d6142d1a6e7c608 end

func Sha224Hmac added in v5.5.0

func Sha224Hmac(c zc.Calc)

oper sha224hmac func Sha224Hmac p0:Str key:Str -- Str title SHA-224 keyed hash function

desc Hash *p0* with *key* using the SHA-224 function end

example 'Behind the tree!' /swordfish -- Behind the tree! | swordfish sha224hmac -- 0x30ecbacd9aedf890b796eb79032105382ce323f18835f9bbb3867c4a end

func Sha256 added in v5.5.0

func Sha256(c zc.Calc)

oper sha256 func Sha256 p0:Str -- Str title SHA-256 hash function

desc Hash *p0* with the SHA-256 function. end

example 'Behind the tree! -- Behind the tree! sha256 -- 0x5e19fc5f8ec2aabccef7970385bb9151a421f398d048ced2b2c86757aafebfc3 end

func Sha256Hmac added in v5.5.0

func Sha256Hmac(c zc.Calc)

oper sha256hmac func Sha256Hmac p0:Str key:Str -- Str title SHA-256 keyed hash function

desc Hash *p0* with *key* using the SHA-256 function end

example 'Behind the tree!' /swordfish -- Behind the tree! | swordfish sha256hmac -- 0x0155d56d7485e9db843792ff48b97a1a96ae0655a92ad7c2324d71ed0410b907 end

func Sha384 added in v5.5.0

func Sha384(c zc.Calc)

oper sha384 func Sha384 p0:Str -- Str title SHA-384 hash function

desc Hash *p0* with the SHA-384 function. end

example 'Behind the tree! -- Behind the tree! sha384 -- 0x54489c547782d201bb0c8c2c81e77e034695067c98087bd949d13de752dd3843323c7244c1d15776ad52093598420dca end

func Sha384Hmac added in v5.5.0

func Sha384Hmac(c zc.Calc)

oper sha384hmac func Sha384Hmac p0:Str key:Str -- Str title SHA-384 keyed hash function

desc Hash *p0* with *key* using the SHA-384 function end

example 'Behind the tree!' /swordfish -- Behind the tree! | swordfish sha384hmac -- 0x401d0de7dd5cdf1ed82002cc1a696ec8d3d636b0388b89cc6f33ec4b237382a16b976f4773c3b0a3979392289a0ceaf9 end

func Sha512 added in v5.5.0

func Sha512(c zc.Calc)

oper sha512 func Sha512 p0:Str -- Str title SHA-512 hash function

desc Hash *p0* with the SHA-512 function. end

example 'Behind the tree! -- Behind the tree! sha512 -- 0x431777a80ed22c45b4fe0dc8c7e3a07d8d20df3b796a39068f2fc6f57cd69b6c60f4a6e3151189b97a1ad2fe5888c255e93f28c1e6c9b6f0241b10c34f8f9e86 end

func Sha512Hmac added in v5.5.0

func Sha512Hmac(c zc.Calc)

oper sha512hmac func Sha512Hmac p0:Str key:Str -- Str title SHA-512 keyed hash function

desc Hash *p0* with *key* using the SHA-512 function end

example 'Behind the tree!' /swordfish -- Behind the tree! | swordfish sha512hmac -- 0x8e4074cf371bc7e83cd508e9a3d4c0ecd9e014aa808f3234b05de26ddad9895ad6d375651b3ac8231806ccd0b9cd477f3df024c1ecd75032a0e827e7f2f98fcf end

func Shuffle

func Shuffle(c zc.Calc)

oper shuffle func Shuffle Val* -- Val* title Shuffle the stack

desc Shuffle the stack. end

example 0 rand-seed -- *seed set to 0* 1 2 3 4 5 6 -- 1 | 2 | 3 | 4 | 5 | 6 shuffle -- 5 | 4 | 1 | 3 | 2 | 6 end

func SignBigFloat

func SignBigFloat(c zc.Calc)

func SignBigInt

func SignBigInt(c zc.Calc)

oper sign func SignBigInt p0:BigInt -- Int func SignDecimal p0:Decimal -- Int func SignBigFloat p0:BigFloat -- Int func SignFloat p0:Float -- Int func SignRational p0:Rational -- Int title Sign

desc Returns `-1` if *p0* is negative, `1` if *p0* is positive, or `0` if *p0* is zero. end

example c -6 sign -- -1 c 6 sign -- 1 c 0 sign -- 0 end

func SignDecimal

func SignDecimal(c zc.Calc)

func SignFloat

func SignFloat(c zc.Calc)

func SignRational

func SignRational(c zc.Calc)

func SinComplex

func SinComplex(c zc.Calc)

oper sin func SinComplex p0:Complex -- Complex title Sine

desc Sine of *p0*. end

example 2+2i sin 5 round -- 3.42095-1.50931i end

func SinFloat

func SinFloat(c zc.Calc)

oper sin func SinFloat p0:Float -- Float title Sine

desc Sine of *p0* in radians. end

example 2 sin 5 round -- 0.9093 end

func SinhComplex

func SinhComplex(c zc.Calc)

oper sinh func SinhComplex p0:Complex -- Complex title Hyperbolic sine

desc Hyperbolic sine of *p0*. end

example 2+2i sinh 5 round -- -1.50931+3.42095i end

func SinhFloat

func SinhFloat(c zc.Calc)

oper sinh func SinhFloat p0:Float -- Float title Hyperbolic sine

desc Hyperbolic sine of *p0* in radians. end

example 2 sinh 5 round -- 3.62686 end

func Size

func Size(c zc.Calc)

oper size func Size Val* -- Val* n:Int title Size of the current stack alias n

desc Number of items on the stack. end

example 1 1 1 1 -- 1 | 1 | 1 | 1 n -- 1 | 1 | 1 | 1 | 4 # size end

func Sort

func Sort(c zc.Calc)

oper sort func Sort Val* -- Val* title Type-aware stack sort

desc Sorts the stack in a type-aware way. When two elements on the stack are compared for their sort order, a common type between those values is found and the comparison operation uses that type. If a common type cannot be found, the comparison is performed as plain text. Use `sort-str` to treat all values on the stack as strings. end

example c 3 1 2 sort -- 1 | 2 | 3 c 003 01.1 2 sort -- 01.1 | 2 | 003 end

func SortStr

func SortStr(c zc.Calc)

oper sort-str func SortStr Val* -- Val* title String based stack sort

desc Sorts the stack by their values as strings. Use `sort` for a type-aware sort. end

example c 003 01.1 2 sort-str -- 003 | 01.1 | 2 end

func Split

func Split(c zc.Calc)

oper split func Split p0:Str sep:Str -- Str* title Split string

desc Split *p0* into multiple strings that are separated by *sep*. end

example 128.8.74.2 -- 128.8.74.2 '.' split -- 128 | 8 | 74 | 2 end

func SplitBits added in v5.5.0

func SplitBits(c zc.Calc)

oper split-bits func SplitBits p0:BigInt n:Int -- BigInt* alias splitb title Split a binary number by bit width

desc Split *p0* every *n* bits starting with the least significant bit. end

example c 0xabcd 4 splitb /hex map -- 0xa | 0xb | 0xc | 0xd c 0xabcd 8 splitb /hex map -- 0xab | 0xcd end

func SqrtBigFloat

func SqrtBigFloat(c zc.Calc)

oper sqrt func SqrtFloat p0:Float -- Float func SqrtBigFloat p0:BigFloat -- BigFloat func - p0:Float -- Complex func SqrtComplex p0:Complex -- Complex alias square-root title Square root

desc The square root of *p0*. If *p0* is a positive or zero then a Float is returned. If *p0* is negative, a Complex is returned. end

example 256 -- 256 sqrt -- 16 end

func SqrtComplex

func SqrtComplex(c zc.Calc)

func SqrtFloat

func SqrtFloat(c zc.Calc)

func Store

func Store(c zc.Calc)

oper store func Store Val* -- Val* alias st title Store stack to memory

desc Store a copy of the current stack to memory for later recall. Memory is also a stack so that multiple stacks can be stored at one time. end

example 1 2 3 4 store average -- 2.5 recall -- 1 | 2 | 3 | 4 | 2.5 end

func SubBigFloat

func SubBigFloat(c zc.Calc)

func SubBigInt

func SubBigInt(c zc.Calc)

oper sub func SubBigInt p0:BigInt p1:BigInt -- BigInt func SubDecimal p0:Decimal p1:Decimal -- Decimal func SubBigFloat p0:BigFloat p1:BigFloat -- BigFloat func SubFloat p0:Float p1:Float -- Float func SubRational p0:Rational p1:Rational -- Rational func SubComplex p0:Complex p1:Complex -- Complex alias s alias - title Subtraction

desc Subtract *p1* from *p0*. end

example 6 -- 6 2 -- 6 | 2 s -- 4 end

func SubComplex

func SubComplex(c zc.Calc)

func SubDateTime

func SubDateTime(c zc.Calc)

func SubDateTimeDuration

func SubDateTimeDuration(c zc.Calc)

func SubDecimal

func SubDecimal(c zc.Calc)

func SubDuration

func SubDuration(c zc.Calc)

oper sub func SubDuration p0:Duration p1:Duration -- Duration func SubDateTimeDuration p0:DateTime p1:Duration -- Duration func SubDateTime p0:DateTime p1:DateTime -- Duration alias s alias - title Time or duration subtraction desc Subtracts a duration from a time or subtracts two durations. end

example c 3:30pm 2h sub -- Mon Jan 2 2006 1:30:00pm -0700 MST c 2h30m 45m sub -- 1h 45m c 3:30pm 1:30pm sub -- 2h end

func SubFloat

func SubFloat(c zc.Calc)

func SubRational

func SubRational(c zc.Calc)

func Swap

func Swap(c zc.Calc)

oper swap func Swap p0:Val p1:Val -- p1:Val p0:Val alias sw title Swap top two items on the stack

desc Swap the first two items on the stack. end

example 1 2 -- 1 | 2 swap -- 2 | 1 swap -- 1 | 2 end

func Take

func Take(c zc.Calc)

oper take func Take Val* n:Int -- Val* title Take elements from the stack

desc Take the top *n* elements from the stack and discard the rest. end

example 1 2 3 4 5 -- 1 | 2 | 3 | 4 | 5 2 take -- 4 | 5 end

func TanComplex

func TanComplex(c zc.Calc)

oper tan func TanComplex p0:Complex -- Complex title Tangent

desc Tangent of *p0*. end

example 2+2i tan 5 round -- -0.02839+1.02384i end

func TanFloat

func TanFloat(c zc.Calc)

oper tan func TanFloat p0:Float -- Float title Tangent

desc Tangent of *p0* in radians. end

example 2 tan 5 round -- -2.18504 end

func TanhComplex

func TanhComplex(c zc.Calc)

oper tanh func TanhComplex p0:Complex -- Complex title Hyperbolic tangent

desc Hyperbolic tangent of *p0*. end

example 2+2i tanh 5 round -- 1.02384-0.02839i end

func TanhFloat

func TanhFloat(c zc.Calc)

oper tanh func TanhFloat p0:Float -- Float title Hyperbolic tangent

desc Hyperbolic tangent of *p0* in radians. end

example 2 tanh 5 round -- 0.96403 end

func Time

func Time(c zc.Calc)

oper time func Time p0:DateTime -- Time title Formats to a common time layout

desc Formats a date/time with the common time layout. Date information, if any, is discarded. end

example '2006-01-02T15:04:05 UTC -- 2006-01-02T15:04:05 UTC time -- 3:04:05pm UTC end

func TimeZone

func TimeZone(c zc.Calc)

oper timezone func TimeZone p0:DateTime zone:Str -- DateTime alias tz title Convert time to another time zone

desc Converts time *p0* to a given time *zone*. end

example now -- Mon Jan 2 2006 3:04:05pm -0700 MST [PST] tz -- Mon Jan 2 2006 2:04:05pm -0800 PST Asia/Jakarta tz -- Tue Jan 3 2006 5:04:05am +0700 WIB end

func Tone

func Tone(c zc.Calc)

oper tone func Tone p0:Str tone:Int -- Str title Apply a skin tone to an emoji

desc Apply a skin *tone*, an integer between 1 and 5 inclusive, to the first character in *p0* which should be an emoji that supports a skin tone. end

example :waving-hand: -- 👋 2 tone -- 👋🏽 end

func UTF8Decode

func UTF8Decode(c zc.Calc)

oper utf8-decode func UTF8Decode p0:BigInt -- Str alias u8de title Decode UTF-8 bytes

desc Decode UTF-8 bytes in *p0* into to a string. end

example 0x3534c2b0 -- 0x3534c2b0 utf8-decode -- 54° end

func UTF8Encode

func UTF8Encode(c zc.Calc)

oper utf8-encode func UTF8Encode p0:Str -- BigInt alias u8en title Encode UTF-8 bytes

desc Encode a string into UTF-8 bytes. end

example 54° -- 54° utf8-encode hex -- 0x3534c2b0 end

func UTM

func UTM(c zc.Calc)

oper epsg.utm func UTM p0:Str -- Str title Universal Transverse Mercator (WGS-84)

desc The EPGS code for the given UTM zone *p0*. The zone should be a number between 1 and 60 inclusive and is followed by a hemisphere designator of 'n' or 's'. end

example 17n epsg.utm -- EPSG:32617 end

func Unescape added in v5.10.0

func Unescape(c zc.Calc)

oper unescape func Unescape p0:Str -- Str alias unesc title Unescape

desc Unescapes characters in a string value that are prefixed by a backslash. The escape sequences as defined for Go strings are used. A value such as `\n` is converted to a new line. Values such as `\x7f`, `\u007f`, '\U0000007f`, and `\077` are converted to the characters of that code point. end

example "\u65e5\u672c\u8a9e" -- \u65e5\u672c\u8a9e unescape -- 日本語 c "\U000065e5\U0000672c\U00008a9e" -- \U000065e5\U0000672c\U00008a9e unescape -- 日本語 c "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" -- \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e unescape -- 日本語 end

func Up

func Up(c zc.Calc)

oper up func Up Val* -- Val* title Rotate items upward

desc Rotate items on the stack by moving upward.

In the interactive calculator, the top of the stack is towards the bottom of the terminal so upwards means seeing all items move toward the top. The bottom of the stack wraps around to be the top of the stack. end

example 1 2 3 -- 1 | 2 | 3 up -- 2 | 3 | 1 up -- 3 | 1 | 2 end

func Upper

func Upper(c zc.Calc)

oper upper func Upper p0:Str -- Str title Uppercase

desc Convert string *p0* to uppercase. end

example 'AbCd -- AbCd upper -- ABCD end

func VariancePop

func VariancePop(c zc.Calc)

oper variance-pop func VariancePop BigInt* -- BigInt func - Decimal* -- Decimal func - Float* -- Float func - Rational* -- Rational alias var-p title Population variance

desc Variance of the stack where it contains the entire population end

example 2 4 4 4 5 5 7 9 -- 2 | 4 | 4 | 4 | 5 | 5 | 7 | 9 var-p -- 4 end

func VarianceSamp

func VarianceSamp(c zc.Calc)

oper variance-samp func VarianceSamp BigInt* -- BigInt func - Decimal* -- Decimal func - Float* -- Float func - Rational* -- Rational alias var-s title Sample variance

desc Variance of the stack where it contains a sample of the population end

example 2 4 4 4 5 5 7 9 -- 2 | 4 | 4 | 4 | 5 | 5 | 7 | 9 var-s 2 round -- 4.57 end

func Version

func Version(c zc.Calc)

oper version func Version -- title Version number

desc Version number of the calculator. end

func Xor

func Xor(c zc.Calc)

oper xor func Xor p0:BigInt p1:BigInt -- BigInt title Bitwise exclusive or

desc The bitwise exclusive or of `p0` and `p1`. end

example 0b1100 -- 0b1100 0b1010 -- 0b1100 | 0b1010 xor bin -- 0b110 end

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL