datatypes

It is implemented in the library, datatypes to check the data type of the value.

isInt or isInteger

returns #T (true) if the value is integer

isDouble

returns #T (true) if the value is double

isString

returns #T (true) if the value is string

isBoolean

returns #T (true) if the value is boolean

isDate

returns #T (true) if the value is date

isSet

returns #T (true) if the value is set

isList

returns #T (true) if the value is list

instanceOf

returns #T (true) if the value is of the specified datatype

isInt or isInteger

Returns #T (true) if the value is an integer.

isInt(Value)
isInteger(Value)

Where:

  • Value is the value to be checked if it is an integer.

Example
@library("dt:","datatypes").

anumber(123).
notanumber("abc").
result(X) :- anumber(Y), X = dt:isInt(Y).
result(Y) :- notanumber(X), Y = dt:isInt(X).

@output("result").
Expected results
result(#T)
result(#F)

isDouble

Returns #T (true) if the value is a double.

isDouble(Value)

Where:

  • Value is the value to be checked if it is a double.

Example
@library("dt:","datatypes").

anumber(123).
notanumber("abc").

result(X) :- anumber(Y), X = dt:isDouble(123.45).
result(Y) :- notanumber(X), Y = dt:isDouble("abc").

@output("result").
Expected results
result(#T)
result(#F)

isString

Returns #T (true) if the value is a string.

isString(Value)

Where:

  • Value is the value to be checked if it is a string.

Example
@library("dt:","datatypes").

notastring(123).
astring("abc").

result(X) :- astring(Y), X = dt:isString(Y).
result(Y) :- notastring(X), Y = dt:isString(X).

@output("result").
Expected results
result(#T)
result(#F)

isBoolean

Returns #T (true) if the value is a boolean.

isBoolean(Value)

Where:

  • Value is the value to be checked if it is a boolean.

Example
@library("dt:","datatypes").

aboolean(#T).
notaboolean("abc").

result(X) :- aboolean(Y), X = dt:isBoolean(Y).
result(Y) :- notaboolean(X), Y = dt:isBoolean(X).

@output("result").
Expected results
result(#T)
result(#F)

isDate

Returns #T (true) if the value is a date.

isDate(Value)

Where:

  • Value is the value to be checked if it is a date.

Example
@library("dt:","datatypes").

adate("2024-06-28").
notadate("abc").

result(X) :- adate(Y), X = dt:isDate(Y).
result(Y) :- notadate(X), Y = dt:isDate(X).

@output("result").
Expected results
result(#T)
result(#F)

isSet

Returns #T (true) if the value is a set.

isSet(Value)

Where:

  • Value is the value to be checked if it is a set.

Example
@library("dt:","datatypes").

aset({1, 2, 3}).
notaset("abc").

result(X) :- aset(Y), X = dt:isSet(Y).
result(Y) :- notaset(X), Y = dt:isSet(X).

@output("result").
Expected results
result(#T)
result(#F)

isList

Returns #T (true) if the value is a list.

isList(Value)

Where:

  • Value is the value to be checked if it is a list.

Example
@library("dt:","datatypes").

alist([1, 2, 3]).
notalist("abc").

result(X) :- alist(Y),X = dt:isList(Y).
result(Y) :- notalist(X),Y = dt:isList(X).

@output("result").
Expected results
result(#T)
result(#F)

instanceOf

Returns #T (true) if the value is of the datatype datatype.

instanceOf(Value, "datatype")

Where:

  • Value is the value to be checked.

  • datatype is the datatype to check against.

Example
@library("dt:","datatypes").

aninstanceofint(123).
notaninstanceofint("abc").

result(X) :- aninstanceofint(Y), X = dt:instanceOf(Y, "integer").
result(Y) :- notaninstanceofint(X), Y = dt:instanceOf(X, "integer").

@output("result").
Expected results
result(#T)
result(#F)