Prelude
Prelude is the base library loaded by default in all k# modules
Types
Numeric types
All numbers are type of trait Num a. Other numeric types are:
Byte: number of 8 bitsShort: number of 16 bitsInt: number of 32 bitsLong: number of 64 bitsBigInt: for larger numbers more of 64 bitsFloat: decimal number of 32 bitsDouble: decimal number of 64 bitsBigDecimal: for large decimal more of 64 bits
Inference of constant numeric types
Constant numeric follow this rules:
- If the number is used in a function the the number is coerced to the expected argument type
- In case the argument type is not defined in the function then
- If number is decimal choose
Double - If the number is integer choose
IntorLongdepending of the number size.
- If number is decimal choose
Warning
Coercion follow the following rules:
decimaltypes can coerce to anintegertype- number must fit into the type. e.g. Compiler can allow coerce
10000into aBytetype
Numeric trait
(+) a a: addition(-) a a: subtraction(*) a a: multiplication(/) a a: division(%) a a: modulus(**) a a: exponentiation
Character types
Char: a character e.g.'a'String: a list of character e.g."Hello World"
note
A string is also interpreted as List Char
Collection types
Listis a collection of the same type e.g.List IntSetnot allow duplicates. e.g.Set IntMapkey value store. e.g.Map String Int