[[Documentation]]
#author("2019-06-28T11:55:24+09:00","default:LMNtal","LMNtal")
//[[Documentation]]

*Built-in Types
*Built-in Types [#c8ed71a5]

The currently supported built-in types are integers,
floating point numbers, and strings.

Some other data types (e.g., arrays) are currently supported by
Some other data types (e.g., arrays) are supported by
library API.

**Numbers
**Numbers [#c5245986]

Integer arithmetics and floating point number arithmetics are available.
Some features, for example bit-shift operator or cosine function,
are not yet implemented.
Integer arithmetics and floating-point number arithmetics are available.
//Some features, for example bit-shift operator or cosine function,
//are not yet implemented.
It is important to note that '''all numbers are unary (i.e., one-argument) atoms.'''  This is because, in most applicatinos, numbers are linked from 
other atoms representing larger expressions, data structures, processes, etc.
In order to represent a (multi)set of numbers, the standard technique is to
use a unary atom (san 'n' in the example below) holding each element.

Atoms are treated as numbers only if
they are unary (i.e., one-argument) atoms.

***Syntax
***Syntax by examples [#c4ccef48]

 X = -2, p(345)
 X = 2.0, p(-3.14e-10)
 X = -2
 factorial(10, result)
 p(-3.14e-10)
 {n(2), n(3), n(5), n(7)}

***Operations
Currently, the following operations are available:
***Operations [#sb1413f4]

 int(+Float,-Int)           - cast
 float(+Int,-Float)         - cast
 '+'(+Int,+Int,-Int)        - integer operation,  as well as: - * / mod
 '+.'(+Float,+Float,-Float) - floating operation, as well as: -. *. /.
There are two ways of performing arithmetic operations:
++ as explicit rewriting of arithmetic expressions and 
++ as operations in the guard of rewrite rules.

**Strings
Here we describe the first approach that is provided by built-in rules '''that are enabled when the''' ''--use-builtin-rule'' '''option is provided'''.  With the ''--use-builtin-rule'' option, '+'(3,5,X) (that can be written also as X=3+5) will be reduced to 8(X) (or X=8).  The following operations are available and can be written as binary operators, where + stands for operands and - stands for the result of operations.

Strings (such as "abc") are unary atom names and
can be distinguished from symbols (such as 'abc' or just abc).
// int(+Float,-Int)           - cast
// float(+Int,-Float)         - cast
:'+'(+L,+M,-N)|integer addition, similarly for ''&color(#8B4513){'-'};'', ''&color(#8B4513){'*'};'', ''&color(#8B4513){'/'};'', ''&color(#8B4513){mod};''
:'+.'(+A,+B,-C)|floating-point addition, similarly for ''&color(#8B4513){'-.'};'', ''&color(#8B4513){'*.'};'', ''&color(#8B4513){'/.'};''

Wtring literals are treated as strings
Arithmetic operations can also be specified in the [[Guards]] of rules, in which case the operations are performed as part of reduction.  See [[Guards]] for further details.

**Strings [#g2049983]

Strings (such as "abc") are unary atom names that
are distinguished from ordinary symbols (such as 'abc' or just abc).
String literals are treated as strings
only if they are unary;
otherwise, they are treated as symbols.
otherwise, they are treated as ordinary symbols.

***Syntax
***Syntax by examples [#mbceb06c]

 X = "abc", p("abc\\de\"\nf\
 X = "abc"
 p("abc\\de\"\nf\
 g")
 X = "abc", p([:abc\de"

The argument in the second example is in a C-like format.

LMNtal provides another quoted format enclosed by [: and :] like

 p([:abc\de"
 fg:])

The former argument to p is in C-like format
and the latter is in 'multiline-quoted format',
expressing the same string.
Note that
the literal [::] expresses an empty string ("").
This represents an multi-line symbolic atom name rather than a string.

***Operations
***Operations [#n29a3450]

Operations on strings are supported by the library API
(string module).
Operations on strings are supported by the [[string>Library Reference#string]]
library API.


Front page List of pages Search Recent changes Backup   Help   RSS of recent changes