TeSSLa Standard Library for TeSSLa 1.2.1

module String

Strings

ANCHOR concat

liftable concat(str1: strict String, str2: strict String): String

Concatenates the string str1 and str2

Usage example:

in x: Events[String]
in y: Events[String]
def result := String.concat(x, y)
out result

Trace example:

option timeDomain: [-1,10]
stream x: bubbles
stream y: bubbles
stream result: signal
---
1: x = X
2: y = A
2: result = XA
4: y = B
4: result = XB
6: x = Y
6: result = YB
8: x = Z
8: result = ZB
liftable def concat(str1: strict String, str2: strict String): String = extern("String_concat")

ANCHOR format

liftable format[T](formatString: strict String, value: strict T): String

Returns a formatted string from the given format and argument. In the TeSSLa software backend, the format specifier has the syntax %[flags][width][.precision]type, where the following types and flags are supported:

type           allowed types   Behaviour
------------   -------------   ------------------------------------------------------------------
x, X           Int             Converts an integer to hexadecimal representation
s, S           all             Converts the type to string using toString
d              Int             Format the value as a decimal integer
o              Int             Format the value as an octal integer
e              Float           Format with scientific notation
f              Float           Format as decimal number
g, G           Float           Scientific notation or decimal depending on precision and rounding
a, A           Float           Hexadecimal floating-point number with significand and exponent
flag   Behaviour
----   ----------------------------------------------
 -     Left justify within the given field of the given width.
 +     Precede the output with a +, unless the value is negative.
 ␣     If no sign is written, write a space (0x20) instead.
 #     Alternative form:
         Precede with 0 for o, 0x for x and 0X for X.
         Always include a decimal point for f, g, e, a, A.
 0     Left-pad the number with 0 if a padding is specified.
 ,     Use a locale-specific grouping separator.
 (     Enclose negative numbers with parenthesis.

Usage example:

in x: Events[Int]
def result := String.format("%#05x", x)
out result

Trace example:

option timeDomain: [-1,10]
stream x: events
stream result: signal
---
1: x = 5
1: result = "0x005"
4: x = 100
4: result = "0x064"
7: x = 10000
7: result = "0x2710"
liftable def format[T](formatString: strict String, value: strict T): String = extern("String_format")

ANCHOR formatFloat

liftable formatFloat(formatString: String, value: Float): String

Formats a float argument with the given format string

liftable def formatFloat(formatString: String, value: Float): String = format(formatString, value)

ANCHOR formatInt

liftable formatInt(formatString: String, value: Int): String

Formats an integer argument with the given format string

liftable def formatInt(formatString: String, value: Int): String = format(formatString, value)