📄 slangfun.txt
字号:
DESCRIPTION The `exp' function computes the exponential of a number and returns the result as an array. If its argument is an array, the `exp' function will be applied to each element and the result returned as an array. SEE ALSO cos, atan, acosh, cosh--------------------------------------------------------------log SYNOPSIS Compute the logarithm of an number USAGE y = log (x) DESCRIPTION The `log' function computes the logarithm of a number and returns the result as an array. If its argument is an array, the `log' function will be applied to each element and the result returned as an array. SEE ALSO cos, atan, acosh, cosh--------------------------------------------------------------log10 SYNOPSIS Compute the base-10 logarithm of an number USAGE y = log10 (x) DESCRIPTION The `log10' function computes the base-10 logarithm of a number and returns the result as an array. If its argument is an array, the `log10' function will be applied to each element and the result returned as an array. SEE ALSO cos, atan, acosh, cosh--------------------------------------------------------------mul2 SYNOPSIS Multiply a number by 2 USAGE y = mul2(x) DESCRIPTION The `mul2' function multiplies an arithmetic type by two and returns the result. If its argument is an array, a new array will be created whose elements are obtained from the original array by using the `mul2' function. SEE ALSO sqr, abs--------------------------------------------------------------polynom SYNOPSIS Evaluate a polynomial USAGE Double_Type polynom(Double_Type a, b, ...c, Integer_Type n, Double_Type x) DESCRIPTION The `polynom' function returns the value of the polynomial expression: ax^n + bx^(n - 1) + ... c NOTES The `polynom' function should be extended to work with complex and array data types. The current implementation is limited to `Double_Type' quantities. SEE ALSO exp--------------------------------------------------------------set_float_format SYNOPSIS Set the format for printing floating point values. USAGE set_float_format (String_Type fmt) DESCRIPTION The `set_float_format' function is used to set the floating point format to be used when floating point numbers are printed. The routines that use this are the traceback routines and the `string' function. The default value is `"%f"' EXAMPLE s = string (PI); % --> s = "3.14159" set_float_format ("%16.10f"); s = string (PI); % --> s = "3.1415926536" set_float_format ("%10.6e"); s = string (PI); % --> s = "3.141593e+00" SEE ALSO string, sprintf, double--------------------------------------------------------------sign SYNOPSIS Compute the sign of a number USAGE y = sign(x) DESCRIPTION The `sign' function returns the sign of an arithmetic type. If its argument is a complex number (`Complex_Type'), it returns the sign of the imaginary part of the number. If the argument is an array, a new array will be created whose elements are obtained from the original array by using the `sign' function. When applied to a real number or an integer, the `sign' function returns -1, 0, or `+1' according to whether the number is less than zero, equal to zero, or greater than zero, respectively. SEE ALSO abs--------------------------------------------------------------sin SYNOPSIS Compute the sine of an number USAGE y = sin (x) DESCRIPTION The `sin' function computes the sine of a number and returns the result as an array. If its argument is an array, the `sin' function will be applied to each element and the result returned as an array. SEE ALSO cos, atan, acosh, cosh--------------------------------------------------------------sinh SYNOPSIS Compute the hyperbolic sine of an number USAGE y = sinh (x) DESCRIPTION The `sinh' function computes the hyperbolic sine of a number and returns the result as an array. If its argument is an array, the `sinh' function will be applied to each element and the result returned as an array. SEE ALSO cos, atan, acosh, cosh--------------------------------------------------------------sqr SYNOPSIS Compute the square of a number USAGE y = sqr(x) DESCRIPTION The `sqr' function returns the square of an arithmetic type. If its argument is a complex number (`Complex_Type'), then it returns the square of the modulus. If the argument is an array, a new array will be created whose elements are obtained from the original array by using the `sqr' function. SEE ALSO abs, mul2--------------------------------------------------------------sqrt SYNOPSIS Compute the square root of an number USAGE y = sqrt (x) DESCRIPTION The `sqrt' function computes the square root of a number and returns the result as an array. If its argument is an array, the `sqrt' function will be applied to each element and the result returned as an array. SEE ALSO sqr, cos, atan, acosh, cosh--------------------------------------------------------------tan SYNOPSIS Compute the tangent of an number USAGE y = tan (x) DESCRIPTION The `tan' function computes the tangent of a number and returns the result as an array. If its argument is an array, the `tan' function will be applied to each element and the result returned as an array. SEE ALSO cos, atan, acosh, cosh--------------------------------------------------------------tanh SYNOPSIS Compute the hyperbolic tangent of an number USAGE y = tanh (x) DESCRIPTION The `tanh' function computes the hyperbolic tangent of a number and returns the result as an array. If its argument is an array, the `tanh' function will be applied to each element and the result returned as an array. SEE ALSO cos, atan, acosh, cosh--------------------------------------------------------------error SYNOPSIS Generate an error condition USAGE error (String_Type msg DESCRIPTION The `error' function generates a S-Lang error condition causing the interpreter to start unwinding to top-level. It takes a single string parameter which is displayed on the stderr output device. The error condition may be cleared via an `ERROR_BLOCK' with the `_clear_error' function. Consult \user-manual for more information. EXAMPLE define add_txt_extension (file) { if (typeof (file) != String_Type) error ("add_extension: parameter must be a string"); file += ".txt"; return file; } SEE ALSO verror, _clear_error, message--------------------------------------------------------------message SYNOPSIS Print a string onto the message device USAGE message (String_Type s DESCRIPTION The `message' function will print the string specified by `s' onto the message device. EXAMPLE define print_current_time () { message (time ()); } NOTES The message device will depend upon the application. For example, the output message device for the `jed' editor correspond to the line at the bottom of the display window. The default message device is the standard output device. SEE ALSO vmessage, sprintf, error--------------------------------------------------------------usage SYNOPSIS Generate a usage error USAGE usage (String_Type msg) DESCRIPTION The `usage' function generates a usage exception and displays `msg' to the message device. EXAMPLE Suppose that some function `plot' plots an array of `x' and `y' values. The such a function could be written to issue a usage message if the wrong number of arguments were passed: define plot () { variable x, y; if (_NARGS != 2) usage ("plot (x, y)"); (x, y) = (); % Now do the hard part . . } SEE ALSO error, message--------------------------------------------------------------verror SYNOPSIS Generate an error condition USAGE verror (String_Type fmt, ...) DESCRIPTION The `verror' function performs the same role as the `error' function. The only difference is that instead of a single string argument, `verror' takes a sprintf style argument list. EXAMPLE define open_file (file) { variable fp; fp = fopen (file, "r"); if (fp == NULL) verror ("Unable to open %s", file); return fp; } NOTES In the current implementation, strictly speaking, the `verror' function is not an intrinsic function. Rather it is a predefined S-Lang function using a combination of `Sprintf' and `error'. SEE ALSO error, Sprintf, vmessage--------------------------------------------------------------vmessage SYNOPSIS Print a formatted string onto the message device USAGE vmessage (String_Type fmt, ...) DESCRIPTION The `vmessage' function formats a sprintf style argument list and displays the resulting string onto the message device. NOTES In the current implementation, strictly speaking, the `vmessage' function is not an intrinsic function. Rather it is a predefined S-Lang function using a combination of `Sprintf' and `message'. SEE ALSO message, Sprintf, verror--------------------------------------------------------------__class_id SYNOPSIS Return the class-id of a specified type USAGE Int_Type __class_id (DataType_Type type)) DESCRIPTION This function returns the internal class-id of a specified data type. SEE ALSO typeof, _typeof, __class_type--------------------------------------------------------------__class_type SYNOPSIS Return the class-type of a specified type USAGE Int_Type __class_type (DataType_Type type)) DESCRIPTION Internally S-Lang objects are classified according to four types: scalar, vector, pointer, and memory managed types. For example, an integer is implemented as a scalar, a complex number as a vector, and a string is represented as a pointer. The `__class_type' function returns an integer representing the class-type associated with the specified data type. Specifically, it returns: 0 memory-managed 1 scalar 2 vector 3 pointer SEE ALSO typeof, _typeof, __class_id--------------------------------------------------------------__eqs SYNOPSIS Test for equality between two objects USAGE Int_Type __eqs (a, b) DESCRIPTION This function tests its two arguments for equalit and returns 1 if they are equal, and 0 otherwise. To be equal, the data type of the arguments must match and the values of the objects must reference the same underlying object. EXAMPLE __eqs (1, 1) ===> 1 __eqs (1, 1.0) ===> 0 __eqs ("a", 1) ===> 0 __eqs ([1,2], [1,2]) ===> 0 SEE ALSO typeof, __get_reference NOTES This function should be thought of as a test for "sameness".--------------------------------------------------------------__get_reference SYNOPSIS Get a reference to a global object USAGE Ref_Type __get_reference (String_Type nm) DESCRIPTION This function returns a reference to a global variable or function whose name is specified by `nm'. If no such object exists, it returns `NULL', otherwise it returns a reference. EXAMPLE For example, consider the function: define runhooks (hook) { variable f; f = __get_reference (hook); if (f != NULL) @f (); } This function could be called from another S-Lang function to allow customization of that function, e.g., if the function represents a mode, the hook could be called to setup keybindings for the mode. SEE ALSO is_defined, typeof, eval, autoload, __is_initialized, __uninitialize-----------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -