metanohi/site/projects/enigma/doc/enigma-0.1-html/Built_002dIn-functions.html

180 lines
7.8 KiB
HTML
Raw Normal View History

<html lang="en">
<head>
<title>Built-In functions - Enigma</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Enigma">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Built_002dIn.html#Built_002dIn" title="Built-In">
<link rel="prev" href="Built_002dIn-values.html#Built_002dIn-values" title="Built-In values">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is for Enigma, version 0.1.
Copyright (C) 2010 Niels Serup
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, no Front-Cover Texts, and
no Back-Cover Texts. A copy of the license is included in the
section entitled "GNU Free Documentation License".
This document is also available under the terms of the Creative
Commons Attribution-Share Alike 3.0 (or any later version)
Unported license. A copy of the license is available at
`http://creativecommons.org/licenses/by-sa/3.0/legalcode'.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Built-In-functions"></a>
<a name="Built_002dIn-functions"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="Built_002dIn-values.html#Built_002dIn-values">Built-In values</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Built_002dIn.html#Built_002dIn">Built-In</a>
<hr>
</div>
<h3 class="section">6.2 Functions</h3>
<p><a name="index-built_002din-functions-17"></a>Enigma has few built-in functions. But they do exist.
<p class="noindent"><code>str(OBJECT...)</code>: Converts all supplied values to strings.
<p class="noindent"><code>num(OBJECT...)</code>: Converts all supplied values to numbers.
<p class="noindent"><code>list(OBJECT...)</code>: Puts all supplied values in a list and destroys
nested lists at one level.
<p class="noindent"><code>bool(OBJECT...)</code>: Converts all supplied values to booleans.
<p class="noindent"><code>code(OBJECT...)</code>: Converts all supplied values to code strings.
<p class="noindent"><code>repr(OBJECT...)</code>: Converts all supplied values to representational
strings. Strings get prepended and appended by " characters, code
objects are surrounded by { and }, and so on.
<p class="noindent"><code>type(OBJECT...)</code>: Converts all supplied values to type strings
(string, number, file, etc.).
<p class="noindent"><code>len(OBJECT...)</code>: Converts all supplied values to their length. This
can be used for both strings and lists.
<p class="noindent"><code>clone(OBJECT...)</code>: Clones all supplied values. When an object is
cloned, its value is assigned to a new variable. The list of clones is
returned.
<p class="noindent"><code>slice(LIST|STRING, NUMBER, NUMBER)</code>: Returns a list value sliced
according to the first and second number if the first variable is a
list variable, or a substring if the first variable is a string
variable.
<p class="noindent"><code>loop(FUNCTION, [OBJECT]...)</code>: Executes function until it returns
false. Sends the rest of the specified variables (if any) to the
function as arguments.
<p class="noindent"><code>open(STRING, STRING)</code>: Opens the file by the name of the first
string, using the second string as its guide as to how it should be
opened. "r" means to read, "w" means to write, and "a" means to
append. Returns a file object.
<p class="noindent"><code>close(FILE...)</code>: Closes files.
<p class="noindent"><code>read(FILE)</code>: Reads one character of a file and returns it. If no
more characters are present, an empty string is returned.
<p class="noindent"><code>write(FILE, STRING)</code>: Writes a string to a file.
<p class="noindent"><code>greater(NUMBER, NUMBER...</code>: Checks if the first number is
greater than the rest and returns true or false.
<p class="noindent"><code>lesser(NUMBER, NUMBER...</code>: Checks if the first number is
lesser than the rest and returns true or false.
<p class="noindent"><code>equal(OBJECT, OBJECT...</code>: Checks if the objects are equal and returns
true or false.
<p class="noindent"><code>and(BOOLEAN...)</code>: Checks if all booleans are true and returns true
or false.
<p class="noindent"><code>or(BOOLEAN...)</code>: Checks if at least one boolean is true and returns
true or false.
<p class="noindent"><code>not(BOOLEAN...)</code>: Converts values of true to values of false, and
vice-versa.
<p class="noindent"><code>act(BOOLEAN, FUNCTION, [OBJECT]...)</code>: Run the function with the
optional objects as arguments if the boolean is true.
<p class="noindent"><code>system(STRING...)</code>: Join the strings and run the result as a
system command.
<p class="noindent"><code>add(NUMBER|STRING|CODE|LIST...)</code>: Add objects together. Numbers, strings, code
strings and lists can be used, but only with similar types. The type
of the first object determines what types the rest must be. The result
is stored in the first object and also returned.
<p class="noindent"><code>subtract(NUMBER...)</code>: Subtract numbers from each other. The
first object receives the final number. It is also returned.
<p class="noindent"><code>multiply(NUMBER...)</code>: Multiply numbers with each other. The
first object receives the final number. It is also returned.
<p class="noindent"><code>divide(NUMBER...)</code>: Divide numbers with each other. The
first object receives the final number. It is also returned.
<p class="noindent"><code>mod(NUMBER, NUMBER)</code>: Finds the remainder of the first number
divided with the second number and returns it as a new variable.
<p class="noindent"><code>pow(NUMBER, NUMBER)</code>: Returns first number^second number.
<p class="noindent"><code>log(NUMBER, [NUMBER])</code>: Returns the logarithm of the first
number. If the second number is not specified, the natural logarith is
used.
<p class="noindent"><code>random()</code>: Returns a random number between 0 and 1.
<p class="noindent"><code>abs(NUMBER...)</code>: Sets and returns absolute values of numbers.
<p class="noindent"><code>round(NUMBER, NUMBER)</code>: Rounds the first number with x decimals,
where x is the second number.
<p class="noindent"><code>floor(NUMBER, NUMBER)</code>: Floors the first number with x decimals,
where x is the second number.
<p class="noindent"><code>ceil(NUMBER, NUMBER)</code>: "Ceils" the first number with x decimals,
where x is the second number.
<p class="noindent"><code>sin(NUMBER...)</code>: Sets and returns sine values.
<p class="noindent"><code>cos(NUMBER...)</code>: Sets and returns cosine values.
<p class="noindent"><code>tan(NUMBER...)</code>: Sets and returns tangent values.
<p class="noindent"><code>asin(NUMBER...)</code>: Sets and returns arcsine values.
<p class="noindent"><code>acos(NUMBER...)</code>: Sets and returns arccosine values.
<p class="noindent"><code>atan(NUMBER...)</code>: Sets and returns arctangent values.
<p class="noindent"><code>sinh(NUMBER...)</code>: Sets and returns hyperbolic sine values.
<p class="noindent"><code>cosh(NUMBER...)</code>: Sets and returns hyperbolic cosine values.
<p class="noindent"><code>tanh(NUMBER...)</code>: Sets and returns hyperbolic tangent values.
</body></html>