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

*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 supported by
library API.

**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.
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.


***Syntax by examples [#c4ccef48]

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

***Operations [#sb1413f4]

There are two ways of performing arithmetic operations:
++ as explicit rewriting of arithmetic expressions and 
++ as operations in the guard of rewrite rules.

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.

// 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){'/.'};''

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 ordinary symbols.

***Syntax by examples [#mbceb06c]

 X = "abc"
 p("abc\\de\"\nf\
 g")

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:])

This represents an multi-line symbolic atom name rather than a string.

***Operations [#n29a3450]

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

Reload   New Edit Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes