#author("2019-04-29T18:52:44+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, in LMNtal, all numbers are unary (i.e., one-argument) atoms.

***Syntax by examples [#c4ccef48]

 X = -2, p(345)
 X = 2.0, p(-3.14e-10)

***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: -, *, /, mod
 '+.'(+A,+B,-C) - floating-point addition, similarly for: -., *., /.

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

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