Skip to content

Latest commit

 

History

History
296 lines (216 loc) · 5.63 KB

Predefined functions.md

File metadata and controls

296 lines (216 loc) · 5.63 KB

Predefined functions:

Predefined functions are functions, which are encoded into the source code of the Interpreter. Such functions can be used in any program since they do not need to get implemented by the developer.




List of predefined functions:

Mathematical functions:

sin
Returns the sine value of a specified position.

cos
Returns the cosine value of a specified position.

tan
Returns the tangency value of a specified position.

sqrt
Returns the square root of the specified number.


String functions:

length
Returns the length of the specified string.

substr
Returns a substring.

charAt
Returns the character at the specified position of the string.


Not specified:

isNumber
Returns, wether the specified input represents a number.




sin:

Remarks:

This function returns the sine value of the specified position x. If an incorret argument is passed (e.g. a String), the value 0.00 is returned.


Parameters:

x
Represents the x-position of which the sine value should be dertermined.


Return value:

Sine value of the specified position.


Example:

(defun main () (
    (princ sin(1.2))
))



cos:

Remarks:

This function returns the cosine value of the specified position x. If an incorrect argument is passed (e.g. a String), the value 0.00 is returned.


Parameters:

x
Represents the x-position of which the cosine value should be determined.


Return value:

Cosine value of the specified position.


Example:

(defun main () (
    (princ cos(0.5))
))



tan:

Remarks:

This function returns the tangency value of the specified position x. If an incorrect argument os passed (e.g. a String), the value 0.00 is returned.


Parameters:

x
Represents the x-position of which the tangency value should be determined.


Return value:

Tangency value of the specified position.


Example:

(defun main () (
    (princ tan(1))
))



sqrt:

Remarks:

This function returns the square root of the passed value. If an incorrect argument is passed (e.g. a String), the value 0.00 is returned.


Parameters:

radical
Represents the value, whoose square root should be determined.


Return value:

The square root of the passed radical.


Example:

(defun main () (
    (princ sqrt(25))
))



length:

Remarks:

This function returns the length (in characters) of the passed String. This works as well with numbers or Booleans.


Parameters:

string
Represents the string which length should be determined.


Return value:

The length of the passed String.


Example:

(defun main () (
    (princ length("Hello World"))
))



substr:

Remarks:

Returns the substring between two indices of a passed String. If incorrect indices (e.g. to small or large) are passed, the entire String is returned.


Parameters:

string
String, from which the substring should be created.

begin
Index of the first character to be part of the substring.

end
Index of the last character to be part of the substring.


Return value:

The String's substring of between the two indices.


Example:

(defun main () (
    (princ substr("Hello World" 2 7))
    ;                ^^^^^^^ <- These are part of the substring.
))



charAt:

Remarks:

This function returns the character at the specified position of the specified String.


Parameters:

string
String, in which the character should be determined.

pos
Position, at which the the character should be determined.


Return value:

Character at the specified position in the specified String.


Example:

(defun main () (
    (princ charAt("Hello World" 3))
    ;                 ^ <- This is the returned character.
))

isNumber:

Remarks:

This function returns, wether the passed argument resembles a number.


Parameters:

input
Argument, that should be checked.


Return value:

Wether the passed argument resembles a String or not.


Example:

(defun main () (
    (if (= isNumber("4.56") T) (
        (princ "4.56 is a number.")
    ))
))