FeelEx.Functions (feel_ex v0.2.0)
This module defines a set of functions that may be used on FeelEx values.
These functions can be invoked in expressions.
Summary
Functions
Returns the absolute value of the given number.
Expects a list of bollean values. Returns true if all elements in a list are true, otherwise returns false. If the given list is empty it returns true.
Returns true if any element of the given list is true. Othewise return false. If the given list is empty return false.
Append a list of items to a list.
Performs ceiling operation on the given number.
Performs ceiling operation on the given number, with a given scale.
Given a list of lists, perform concatenation.
Given a string and a match check if string contains a given match, otherwise it returns false.
Constructs a FeelEx context based of a list of context where each context must contain keys:
key
and value
. Returns null if the list contains a value which is not a context, or if a
context, it does not contain the required keys.
Returns the number of elements of the given list.
Returns FeelEx date value from a given string. If date cannot be parsed FeelEx's null value is returned. For example, "2024-06-31" is invalid because June only contains 30 days.
Creates a FeelEx's date value using year, month, day components represented by FeelEx's numbers. If the date components are invalid a FeelEx's null value is returned.
Create date and time value from string.
Create date time value from date and time components.
Given a number and a scale it returns the number at the given scale.
Returns the given list without duplicates.
Returns duplicate values within a list.
Creates a duration from string. FeelEx supports two types of durations:
days-time-duration
and years-months-duration
. With the former containing
day, hour, minute, and second components and the latter containing year and month components.
Given a string and a match. It returns true if the given string ends with match, otherwise it returns false.
Returns true if the given number is even, otherwise returns false.
Returns e raised to the power of the given number.
Performs floor operation on the given number.
Performs floor operation on the given number with a given scale.
Returns 1-based indices of a given list corresponding to a given match.
Returns the given list with newItem inserted at position.
Returns true if the given list is empty. Otherwise, returns false.
Checks if list contains some value.
Returns natural logarithm (base e) of the given number.
Transforms every character in a given string into upper case.
Returns the maximum, in a list. All elements in the list should have the same type and be comparable.
Returns arithmetic mean given a list of numbers. Returns nil when the list is empty or contains an element which is not a number.
Returns the median element of the given list of numbers.
Returns the minimum in a list. All elements in the list should have the same type and be comparable.
Returns the mode of the given list of numbers.
Returns the remainder returned by division of the divedend by the divisor.
Negates a value of type boolean. Returns null on other type of values
Parses a given FeelEx value of type string to a FeelEx value of type integer. Returns FeelEx null value if the string is not a number.
Returns true if the given number is odd, otherwise returns false.
Returns the product of the given list of numbers.
Returns a number between 0 and 1.
Returns the given list without the element at position.
Returns the given list in revered order.
Rounds down a given number with a given scale.
Rounds a number using round-half-up mode.
Rounds a number using round-half-up mode.
Rounds up a given number with a given scale.
Given a string and delimeter it splits string into a list of string, breaking at each occurence of delimeter
Returns the square root of the given value.
Given a string and a match. It returns true if the given string starts with match, otherwise it returns false.
Returns the standard deviation of the given list of numbers.
Returns any FeelEx value as a FeelEx value of type string.
Joins a list of strings into a single string.
Joins a list of strings into a single string, with a delimeter between eech element.
Returns length of a given string.
Returns a partial list of the given value starting at start position.
Returns a partial list of the given value starting at start position. The maximum length of the sublist returned is max_length.
Returns a substring of string using 1-based indexing.
Returns a substring of specified length of string using 1-based indexing.
Given a string and a match it returns all the characters before match.
Given a string and a match it returns all the characters before match.
Returns the sum of the given list of numbers.
Returns FeelEx time value from a given string. If time cannot be parsed FeelEx's null value is returned.
Create a FeelEx's time value using hour, minute and second component.
Create time with hour, minute offset, time and duration FeelEx's components.
Remove leading and trailing spaces from string
Returns a list that includes all elements of the given lists without duplicates.
Transforms every character in a given string into upper case.
Functions
Returns the absolute value of the given number.
Examples
iex> number = FeelEx.Value.new(-1.21)
%FeelEx.Value{value: -1.21, type: :number}
iex> FeelEx.Functions.abs(number)
%FeelEx.Value{value: 1.21, type: :number}
iex> number = FeelEx.Value.new(10)
%FeelEx.Value{value: 10, type: :number}
iex> FeelEx.Functions.abs(number)
%FeelEx.Value{value: 10, type: :number}
Expects a list of bollean values. Returns true if all elements in a list are true, otherwise returns false. If the given list is empty it returns true.
Examples
iex> value = FeelEx.Value.new([true,false])
[
%FeelEx.Value{value: true, type: :boolean},
%FeelEx.Value{value: false, type: :boolean}
]
iex> FeelEx.Functions.all(value)
%FeelEx.Value{value: false, type: :boolean}
iex> value = FeelEx.Value.new([false,nil,true,false])
[
%FeelEx.Value{value: false, type: :boolean},
%FeelEx.Value{value: nil, type: :null},
%FeelEx.Value{value: true, type: :boolean},
%FeelEx.Value{value: false, type: :boolean}
]
iex> FeelEx.Functions.all(value)
%FeelEx.Value{value: false, type: :boolean}
Returns true if any element of the given list is true. Othewise return false. If the given list is empty return false.
Examples
iex> value = FeelEx.Value.new([false,true])
[
%FeelEx.Value{value: false, type: :boolean},
%FeelEx.Value{value: true, type: :boolean}
]
iex> FeelEx.Functions.any(value)
%FeelEx.Value{value: true, type: :boolean}
Append a list of items to a list.
Examples
iex> list = FeelEx.Value.new([1,2,3])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
iex> items = FeelEx.Value.new(["a","b"])
[
%FeelEx.Value{value: "a", type: :string},
%FeelEx.Value{value: "b", type: :string}
]
iex> FeelEx.Functions.append(list,items)
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number},
%FeelEx.Value{value: "a", type: :string},
%FeelEx.Value{value: "b", type: :string}
]
Performs ceiling operation on the given number.
Examples
iex> number = FeelEx.Value.new(1/3)
%FeelEx.Value{value: 0.3333333333333333, type: :number}
iex> FeelEx.Functions.ceiling(number)
%FeelEx.Value{value: 1, type: :number}
Performs ceiling operation on the given number, with a given scale.
Examples
iex> number = FeelEx.Value.new(1/3)
%FeelEx.Value{value: 0.3333333333333333, type: :number}
iex> scale = FeelEx.Value.new(3)
%FeelEx.Value{value: 3, type: :number}
iex> FeelEx.Functions.ceiling(number,scale)
%FeelEx.Value{value: 0.334, type: :number}
Given a list of lists, perform concatenation.
Examples
iex> list = FeelEx.Value.new([1,2,3]) [
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
] iex> items = FeelEx.Value.new([[1,2],["a","b"]]) [ [
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number}
], [
%FeelEx.Value{value: "a", type: :string},
%FeelEx.Value{value: "b", type: :string}
] ]
iex> FeelEx.Functions.concatenate(items) [
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: "a", type: :string},
%FeelEx.Value{value: "b", type: :string}
]
Given a string and a match check if string contains a given match, otherwise it returns false.
iex> string = FeelEx.Value.new("Aw Dinja !!") %FeelEx.Value{value: "Aw Dinja !!", type: :string} iex> match = FeelEx.Value.new("ew") %FeelEx.Value{value: "ew", type: :string} iex> FeelEx.Functions.contains(string,match) %FeelEx.Value{value: false, type: :boolean}
Constructs a FeelEx context based of a list of context where each context must contain keys:
key
and value
. Returns null if the list contains a value which is not a context, or if a
context, it does not contain the required keys.
Examples
iex(79)> value = FeelEx.Value.new([%{key: "a", value: 1},%{key: "b", value: "bee"}])
[
%FeelEx.Value{
value: %{
value: %FeelEx.Value{value: 1, type: :number},
key: %FeelEx.Value{value: "a", type: :string}
},
type: :context
},
%FeelEx.Value{
value: %{
value: %FeelEx.Value{value: "bee", type: :string},
key: %FeelEx.Value{value: "b", type: :string}
},
type: :context
}
]
iex(80)> FeelEx.Functions.context(value)
%FeelEx.Value{
value: %{
a: %FeelEx.Value{value: 1, type: :number},
b: %FeelEx.Value{value: "bee", type: :string}
},
type: :context
}
Returns the number of elements of the given list.
Examples
iex> list = FeelEx.Value.new([1,2,3]) [ %FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 2, type: :number}, %FeelEx.Value{value: 3, type: :number} ] iex> FeelEx.Functions.count(list) %FeelEx.Value{value: 3, type: :number}
Returns FeelEx date value from a given string. If date cannot be parsed FeelEx's null value is returned. For example, "2024-06-31" is invalid because June only contains 30 days.
This function can be used exract a date value from date-time value.
Examples
iex> value = FeelEx.Value.new("2021-01-03")
%FeelEx.Value{value: "2021-01-03", type: :string}
iex> FeelEx.Functions.date(value)
%FeelEx.Value{value: ~D[2021-01-03], type: :date}
iex> value = FeelEx.Value.new(NaiveDateTime.utc_now,"+01:00")
%FeelEx.Value{
value: {~N[2025-01-19 20:40:52.380623], "+01:00"},
type: :date_time
}
iex> FeelEx.Functions.date(value)
%FeelEx.Value{value: ~D[2025-01-19], type: :date}
Creates a FeelEx's date value using year, month, day components represented by FeelEx's numbers. If the date components are invalid a FeelEx's null value is returned.
Examples
iex> year = FeelEx.Value.new(2021)
%FeelEx.Value{value: 2021, type: :number}
iex> month = FeelEx.Value.new(6)
%FeelEx.Value{value: 6, type: :number}
iex> day = FeelEx.Value.new(1)
%FeelEx.Value{value: 1, type: :number}
iex)> FeelEx.Functions.date(year,month,day)
%FeelEx.Value{value: ~D[2021-06-01], type: :date}
Create date and time value from string.
Examples
iex> value = FeelEx.Value.new("2018-04-29T09:30:00")
%FeelEx.Value{value: "2018-04-29T09:30:00", type: :string}
iex> FeelEx.Functions.date_and_time(value)
%FeelEx.Value{value: ~N[2018-04-29 09:30:00], type: :date_time}
iex> value = FeelEx.Value.new("2018-04-29T09:30:00+02:00")
%FeelEx.Value{value: "2018-04-29T09:30:00+02:00", type: :string}
iex> FeelEx.Functions.date_and_time(value)
%FeelEx.Value{value: {~N[2018-04-29 09:30:00], "+02:00"}, type: :date_time}
iex> value = FeelEx.Value.new("2018-04-29T09:30:00@Europe/Malta")
%FeelEx.Value{value: "2018-04-29T09:30:00@Europe/Malta", type: :string}
iex> FeelEx.Functions.date_and_time(value)
%FeelEx.Value{
value: {~N[2018-04-29 09:30:00], "+01:00", "Europe/Malta"},
type: :date_time
}
Create date time value from date and time components.
Examples
iex> date = FeelEx.Value.new(Date.utc_today)
%FeelEx.Value{value: ~D[2025-01-19], type: :date}
iex> date = FeelEx.Value.new(Time.utc_now)
%FeelEx.Value{value: ~T[21:47:33.597814], type: :time}
iex> date = FeelEx.Value.new(Date.utc_today)
%FeelEx.Value{value: ~D[2025-01-19], type: :date}
iex> time = FeelEx.Value.new(Time.utc_now)
%FeelEx.Value{value: ~T[21:47:41.988770], type: :time}
iex> FeelEx.Functions.date_and_time(date,time)
%FeelEx.Value{value: ~N[2025-01-19 21:47:41.988770], type: :date_time}
iex> date_time = FeelEx.Value.new(NaiveDateTime.utc_now)
%FeelEx.Value{value: ~N[2025-01-19 21:58:55.449808], type: :date_time}
iex> time = FeelEx.Value.new(Time.new!(8,2,3))
%FeelEx.Value{value: ~T[08:02:03], type: :time}
iex> FeelEx.Functions.date_and_time(date_time,time)
%FeelEx.Value{value: ~N[2025-01-19 08:02:03], type: :date_time}
Given a number and a scale it returns the number at the given scale.
Examples
iex> number = FeelEx.Value.new(1/3) %FeelEx.Value{value: 0.3333333333333333, type: :number} iex> scale = FeelEx.Value.new(2) %FeelEx.Value{value: 2, type: :number} iex> FeelEx.Functions.decimal(number,scale) %FeelEx.Value{value: 0.33, type: :number}
Returns the given list without duplicates.
Examples
iex> list = FeelEx.Value.new([1,2,3,2,1])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 1, type: :number}
]
iex> FeelEx.Functions.distinct_values(list)
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
Returns duplicate values within a list.
Examples
iex> list = FeelEx.Value.new([1,2,3,2,1]) [
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 1, type: :number}
] iex> FeelEx.Functions.duplicate_value(list) [%FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 2, type: :number}]
Creates a duration from string. FeelEx supports two types of durations:
days-time-duration
and years-months-duration
. With the former containing
day, hour, minute, and second components and the latter containing year and month components.
Examples
iex> value = FeelEx.Value.new("P1DT1H2M") %FeelEx.Value{value: "P1DT1H2M", type: :string} iex> FeelEx.Functions.duration(value) %FeelEx.Value{ value: %Duration{day: 1, hour: 1, minute: 2}, type: :days_time_duration } iex> value = FeelEx.Value.new("P1Y1M") %FeelEx.Value{value: "P1Y1M", type: :string} iex> FeelEx.Functions.duration(value) %FeelEx.Value{value: %Duration{year: 1, month: 1}, type: :years_months_duration}
Given a string and a match. It returns true if the given string ends with match, otherwise it returns false.
Examples
iex> string = FeelEx.Value.new("Aw Dinja !!")
%FeelEx.Value{value: "Aw Dinja !!", type: :string}
iex> match = FeelEx.Value.new("Aw D")
%FeelEx.Value{value: "ja" , type: :string}
iex> FeelEx.Functions.starts_with(string,match)
%FeelEx.Value{value: true, type: :boolean}
Returns true if the given number is even, otherwise returns false.
Examples
iex> value = FeelEx.Value.new(5)
%FeelEx.Value{value: 5, type: :number}
iex> FeelEx.Functions.even(value)
%FeelEx.Value{value: false, type: :boolean}
iex> value = FeelEx.Value.new(6)
%FeelEx.Value{value: 6, type: :number}
iex> FeelEx.Functions.even(value)
%FeelEx.Value{value: true, type: :boolean}
Returns e raised to the power of the given number.
Examples
iex> number = FeelEx.Value.new(5)
%FeelEx.Value{value: 5, type: :number}
iex> FeelEx.Functions.exp(number)
%FeelEx.Value{value: 148.4131591025766, type: :number}
Performs floor operation on the given number.
Examples
iex> number = FeelEx.Value.new(1/3)
%FeelEx.Value{value: 0.3333333333333333, type: :number}
iex> FeelEx.Functions.floor(number)
%FeelEx.Value{value: 0, type: :number}
Performs floor operation on the given number with a given scale.
Examples
iex> number = FeelEx.Value.new(1/3)
%FeelEx.Value{value: 0.3333333333333333, type: :number}
iex> scale = FeelEx.Value.new(3)
%FeelEx.Value{value: 3, type: :number}
iex> FeelEx.Functions.floor(number,scale)
%FeelEx.Value{value: 0.333, type: :number}
Returns 1-based indices of a given list corresponding to a given match.
Examples
iex> list = FeelEx.Value.new([1,2,3,2])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number},
%FeelEx.Value{value: 2, type: :number}
]
iex> value = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.index_of(list,value)
[%FeelEx.Value{value: 2, type: :number}, %FeelEx.Value{value: 4, type: :number}]
Returns the given list with newItem inserted at position.
Examples
iex> list = FeelEx.Value.new([1,3])
[%FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 3, type: :number}]
iex> position = FeelEx.Value.new(1)
%FeelEx.Value{value: 1, type: :number}
iex> value = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.insert_before(list,position,value)
[
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
Returns true if the given list is empty. Otherwise, returns false.
Examples
iex> list = FeelEx.Value.new([]) [] iex> FeelEx.Functions.is_empty(list) %FeelEx.Value{value: true, type: :boolean} iex> list = FeelEx.Value.new([1,2,3]) [ %FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 2, type: :number}, %FeelEx.Value{value: 3, type: :number} ] iex> FeelEx.Functions.is_empty(list) %FeelEx.Value{value: false, type: :boolean}
Checks if list contains some value.
Examples
iex> list = FeelEx.Value.new([1,2,3])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
iex> member = FeelEx.Value.new(1)
%FeelEx.Value{value: 1, type: :number}
iex> FeelEx.Functions.list_contains(list,member)
%FeelEx.Value{value: true, type: :boolean}
Returns natural logarithm (base e) of the given number.
Examples
iex> number = FeelEx.Value.new(10)
%FeelEx.Value{value: 10, type: :number}
iex> FeelEx.Functions.log(number)
%FeelEx.Value{value: 2.302585092994046, type: :number}
Transforms every character in a given string into upper case.
Examples
iex> string = FeelEx.Value.new("Aw Dinja !!") %FeelEx.Value{value: "Aw Dinja !!", type: :string} iex> FeelEx.Functions.upper_case(string) %FeelEx.Value{value: "aw dinja !!", type: :string}
Returns the maximum, in a list. All elements in the list should have the same type and be comparable.
Examples
iex> list = FeelEx.Value.new([2,4,1,2])
[
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 4, type: :number},
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number}
]
iex> FeelEx.Functions.max(list)
%FeelEx.Value{value: 4, type: :number}
Returns arithmetic mean given a list of numbers. Returns nil when the list is empty or contains an element which is not a number.
Examples
iex> list = FeelEx.Value.new([1,2,3])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
iex> FeelEx.Functions.mean(list)
%FeelEx.Value{value: 2, type: :number}
Returns the median element of the given list of numbers.
Examples
iex> value = FeelEx.Value.new([6, 1, 2, 3])
[
%FeelEx.Value{value: 6, type: :number},
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
iex> FeelEx.Functions.median(value)
%FeelEx.Value{value: 2.5, type: :number}
Returns the minimum in a list. All elements in the list should have the same type and be comparable.
Examples
iex> list = FeelEx.Value.new([2,4,1,2])
[
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 4, type: :number},
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number}
]
iex> FeelEx.Functions.min(list)
%FeelEx.Value{value: 1, type: :number}
iex> list = FeelEx.Value.new([2,4,1,"a"])
[
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 4, type: :number},
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: "a", type: :string}
]
iex> FeelEx.Functions.min(list)
[warning] [Elixir.FeelEx.Functions][min/1] Failed to invoke function 'min': [%FeelEx.Value{value: 2, type: :number}, %FeelEx.Value{value: 4, type: :number}, %FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: "a", type: :string}] is not comparable
%FeelEx.Value{value: nil, type: :null}
Returns the mode of the given list of numbers.
Examples
iex> value = FeelEx.Value.new([6, 1, 9, 6, 1])
[
%FeelEx.Value{value: 6, type: :number},
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 9, type: :number},
%FeelEx.Value{value: 6, type: :number},
%FeelEx.Value{value: 1, type: :number}
]
iex> FeelEx.Functions.mode(value)
[%FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 6, type: :number}]
Returns the remainder returned by division of the divedend by the divisor.
Examples
iex> number = FeelEx.Value.new(12)
%FeelEx.Value{value: 12, type: :number}
iex> scale = FeelEx.Value.new(5)
%FeelEx.Value{value: 5, type: :number}
iex> FeelEx.Functions.modulo(number,scale)
%FeelEx.Value{value: 2, type: :number}
Negates a value of type boolean. Returns null on other type of values
Examples
iex> value = FeelEx.Value.new(true)
%FeelEx.Value{value: true, type: :boolean}
iex> FeelEx.Functions.negate(value)
%FeelEx.Value{value: false, type: :boolean}
Parses a given FeelEx value of type string to a FeelEx value of type integer. Returns FeelEx null value if the string is not a number.
Examples
iex> value = FeelEx.Value.new("21")
%FeelEx.Value{value: "21", type: :string}
iex> FeelEx.Functions.number(value)
%FeelEx.Value{value: 21, type: :number}
iex> value = FeelEx.Value.new("21.69")
%FeelEx.Value{value: "21.69", type: :string}
iex> FeelEx.Functions.number(value)
%FeelEx.Value{value: 21.69, type: :number}
iex> value = FeelEx.Value.new("21.69wazzup")
%FeelEx.Value{value: "21.69wazzup", type: :string}
iex> FeelEx.Functions.number(value)
%FeelEx.Value{value: nil, type: :null}
Returns true if the given number is odd, otherwise returns false.
Examples
iex> value = FeelEx.Value.new(5)
%FeelEx.Value{value: 5, type: :number}
iex> FeelEx.Functions.odd(value)
%FeelEx.Value{value: true, type: :boolean}
iex> value = FeelEx.Value.new(6)
%FeelEx.Value{value: 6, type: :number}
iex> FeelEx.Functions.odd(value)
%FeelEx.Value{value: false, type: :boolean}
Returns the product of the given list of numbers.
Examples
iex > list = FeelEx.Value.new([2,4,1,2]) [ %FeelEx.Value{value: 2, type: :number}, %FeelEx.Value{value: 4, type: :number}, %FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 2, type: :number} ] iex > FeelEx.Functions.product(list) %FeelEx.Value{value: 16, type: :number}
Returns a number between 0 and 1.
Examples
iex> FeelEx.Functions.random()
%FeelEx.Value{value: 0.5189989081813825, type: :number}
Returns the given list without the element at position.
Examples
iex> list = FeelEx.Value.new([1,2,3])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
iex> position = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.remove(list,position)
[%FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 3, type: :number}]
Returns the given list in revered order.
Examples
iex> list = FeelEx.Value.new([1,3]) [%FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 3, type: :number}] iex> FeelEx.Functions.reverse(list) [%FeelEx.Value{value: 3, type: :number}, %FeelEx.Value{value: 1, type: :number}]
Rounds down a given number with a given scale.
Examples
iex> number = FeelEx.Value.new(5.5)
%FeelEx.Value{value: 5.5, type: :number}
iex> scale = FeelEx.Value.new(0)
%FeelEx.Value{value: 0, type: :number}
iex> FeelEx.Functions.round_down(number,scale)
%FeelEx.Value{value: 5, type: :number}
Rounds a number using round-half-up mode.
Examples
iex> number = FeelEx.Value.new(5.5)
%FeelEx.Value{value: 5.5, type: :number}
iex> scale = FeelEx.Value.new(0)
%FeelEx.Value{value: 0, type: :number}
iex> FeelEx.Functions.round_half_down(number,scale)
%FeelEx.Value{value: 5, type: :number}
iex> number = FeelEx.Value.new(-5.5)
%FeelEx.Value{value: -5.5, type: :number}
iex> scale = FeelEx.Value.new(0)
%FeelEx.Value{value: 0, type: :number}
iex> FeelEx.Functions.round_half_down(number,scale)
%FeelEx.Value{value: -5, type: :number}
iex> number = FeelEx.Value.new(1.121)
%FeelEx.Value{value: 1.121, type: :number}
iex> scale = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.round_half_down(number,scale)
%FeelEx.Value{value: 1.12, type: :number}
iex> number = FeelEx.Value.new(-1.126)
%FeelEx.Value{value: -1.126, type: :number}
iex> scale = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.round_half_down(number,scale)
%FeelEx.Value{value: -1.13, type: :number}
Rounds a number using round-half-up mode.
Examples
iex> number = FeelEx.Value.new(5.5)
%FeelEx.Value{value: 5.5, type: :number}
iex> scale = FeelEx.Value.new(0)
%FeelEx.Value{value: 0, type: :number}
iex> FeelEx.Functions.round_half_up(number,scale)
%FeelEx.Value{value: 6, type: :number}
iex> number = FeelEx.Value.new(-5.5)
%FeelEx.Value{value: -5.5, type: :number}
iex> scale = FeelEx.Value.new(0)
%FeelEx.Value{value: 0, type: :number}
iex> FeelEx.Functions.round_half_up(number,scale)
%FeelEx.Value{value: -6, type: :number}
iex> number = FeelEx.Value.new(1.121)
%FeelEx.Value{value: 1.121, type: :number}
iex> scale = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.round_half_up(number,scale)
%FeelEx.Value{value: 1.12, type: :number}
iex> number = FeelEx.Value.new(-1.126)
%FeelEx.Value{value: -1.126, type: :number}
iex> scale = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.round_half_up(number,scale)
%FeelEx.Value{value: -1.13, type: :number}
Rounds up a given number with a given scale.
Examples
iex> number = FeelEx.Value.new(1/3)
%FeelEx.Value{value: 0.3333333333333333, type: :number}
iex> scale = FeelEx.Value.new(0)
%FeelEx.Value{value: 0, type: :number}
iex> FeelEx.Functions.round_up(number,scale)
%FeelEx.Value{value: 1, type: :number}
iex> number = FeelEx.Value.new(1.121)
%FeelEx.Value{value: 1.121, type: :number}
iex> scale = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.round_up(number,scale)
%FeelEx.Value{value: 1.13, type: :number}
iex number = FeelEx.Value.new(-1.126)
%FeelEx.Value{value: -1.126, type: :number}
iex scale = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.round_up(number,scale)
%FeelEx.Value{value: -1.13, type: :number}
Given a string and delimeter it splits string into a list of string, breaking at each occurence of delimeter
Examples
iex> FeelEx.evaluate("split("Hello World"," ")")
[
%FeelEx.Value{value: "Hello", type: :string},
%FeelEx.Value{value: "World", type: :string}
]
Returns the square root of the given value.
Examples
iex> number = FeelEx.Value.new(16)
%FeelEx.Value{value: 16, type: :number}
iex> FeelEx.Functions.sqrt(number)
%FeelEx.Value{value: 4, type: :number}
Given a string and a match. It returns true if the given string starts with match, otherwise it returns false.
Examples
iex> string = FeelEx.Value.new("Aw Dinja !!")
%FeelEx.Value{value: "Aw Dinja !!", type: :string}
iex> match = FeelEx.Value.new("Aw D")
%FeelEx.Value{value: "Aw D", type: :string}
iex> FeelEx.Functions.starts_with(string,match)
%FeelEx.Value{value: true, type: :boolean}
Returns the standard deviation of the given list of numbers.
Examples
iex> value = FeelEx.Value.new([2, 4, 7, 5]) [ %FeelEx.Value{value: 2, type: :number}, %FeelEx.Value{value: 4, type: :number}, %FeelEx.Value{value: 7, type: :number}, %FeelEx.Value{value: 5, type: :number} ] iex> FeelEx.Functions.stddev(value) %FeelEx.Value{value: 2.0816659994661326, type: :number}
Returns any FeelEx value as a FeelEx value of type string.
Examples
iex> value = FeelEx.Value.new(1.1)
%FeelEx.Value{value: 1.1, type: :number}
iex> FeelEx.Functions.string(value)
%FeelEx.Value{value: "1.1", type: :string}
iex> value = FeelEx.Value.new([1,2])
[%FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 2, type: :number}]
iex> FeelEx.Functions.string(value)
%FeelEx.Value{value: "[1, 2]", type: :string}
Joins a list of strings into a single string.
Examples
iex> list = FeelEx.Value.new(["a","b","c"])
[
%FeelEx.Value{value: "a", type: :string},
%FeelEx.Value{value: "b", type: :string},
%FeelEx.Value{value: "c", type: :string}
]
iex> FeelEx.Functions.string_join(list)
%FeelEx.Value{value: "abc", type: :string}
iex> list = FeelEx.Value.new(["a",nil,"c"])
[
%FeelEx.Value{value: "a", type: :string},
%FeelEx.Value{value: nil, type: :null},
%FeelEx.Value{value: "c", type: :string}
]
iex> FeelEx.Functions.string_join(list)
%FeelEx.Value{value: "ac", type: :string}
Joins a list of strings into a single string, with a delimeter between eech element.
Examples
iex)> list = FeelEx.Value.new(["a"]) [%FeelEx.Value{value: "a", type: :string}] iex)> delimiter = FeelEx.Value.new("X") %FeelEx.Value{value: "X", type: :string} iex)> FeelEx.Functions.string_join(list,delimiter) %FeelEx.Value{value: "a", type: :string} iex> list = FeelEx.Value.new(["a","b","c"]) [ %FeelEx.Value{value: "a", type: :string}, %FeelEx.Value{value: "b", type: :string}, %FeelEx.Value{value: "c", type: :string} ] iex> delimiter = FeelEx.Value.new(", ") %FeelEx.Value{value: ", ", type: :string} iex> FeelEx.Functions.string_join(list,delimiter) %FeelEx.Value{value: "a, b, c", type: :string}
Returns length of a given string.
Examples
iex> string = FeelEx.Value.new("Aw dinja")
%FeelEx.Value{value: "Aw dinja", type: :string}
iex> FeelEx.Functions.string_length(string)
%FeelEx.Value{value: 8, type: :number}
Returns a partial list of the given value starting at start position.
Examples
iex> value = FeelEx.Value.new([1,2,3])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
iex> start_index = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.sublist(value,start_index)
[%FeelEx.Value{value: 2, type: :number}, %FeelEx.Value{value: 3, type: :number}]
Returns a partial list of the given value starting at start position. The maximum length of the sublist returned is max_length.
Examples
iex> value = FeelEx.Value.new([1,2,3])
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
iex> length = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> start_index = FeelEx.Value.new(1)
%FeelEx.Value{value: 1, type: :number}
iex> FeelEx.Functions.sublist(value,start_index,length)
[%FeelEx.Value{value: 1, type: :number}, %FeelEx.Value{value: 2, type: :number}]
Returns a substring of string using 1-based indexing.
Examples
iex> string = FeelEx.Value.new("Aw dinja")
%FeelEx.Value{value: "Aw dinja", type: :string}
iex> index = FeelEx.Value.new(4)
%FeelEx.Value{value: 4, type: :number}
iex> FeelEx.Functions.substring(string,index)
%FeelEx.Value{value: "dinja", type: :string}
Returns a substring of specified length of string using 1-based indexing.
Examples
iex> string = FeelEx.Value.new("Aw dinja")
%FeelEx.Value{value: "Aw dinja", type: :string}
iex> index = FeelEx.Value.new(4)
%FeelEx.Value{value: 4, type: :number}
iex> length = FeelEx.Value.new(2)
%FeelEx.Value{value: 2, type: :number}
iex> FeelEx.Functions.substring(string,index,length)
%FeelEx.Value{value: "di", type: :string}
iex> string = FeelEx.Value.new("Aw dinja")
%FeelEx.Value{value: "Aw dinja", type: :string}
iex> index = FeelEx.Value.new(4)
%FeelEx.Value{value: 4, type: :number}
iex> FeelEx.Functions.substring(string,index)
%FeelEx.Value{value: "dinja", type: :string}
Given a string and a match it returns all the characters before match.
Examples
iex> string = FeelEx.Value.new("Aw Dinja !!")
%FeelEx.Value{value: "Aw Dinja !!", type: :string}
iex> match = FeelEx.Value.new(" Di")
%FeelEx.Value{value: " Di", type: :string}
iex> FeelEx.Functions.substring_after(string,match)
%FeelEx.Value{value: "nja !!", type: :string}
Given a string and a match it returns all the characters before match.
Examples
iex> string = FeelEx.Value.new("Aw Dinja !!")
%FeelEx.Value{value: "Aw Dinja !!", type: :string}
iex> match = FeelEx.Value.new(" Di")
%FeelEx.Value{value: " Di", type: :string}
iex> FeelEx.Functions.substring_before(string,match)
%FeelEx.Value{value: "Aw", type: :string}
Returns the sum of the given list of numbers.
Examples
iex> list = FeelEx.Value.new([2,4,1,2])
[
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 4, type: :number},
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number}
]
iex> FeelEx.Functions.sum(list)
%FeelEx.Value{value: 9, type: :number}
iex> FeelEx.Functions.sum(list)
[warning] [Elixir.FeelEx.Functions][sum/1] Failed to invoke function 'sum': expected number but found '%FeelEx.Value{value: "a", type: :string}'
%FeelEx.Value{value: nil, type: :null}
Returns FeelEx time value from a given string. If time cannot be parsed FeelEx's null value is returned.
This function can be used exract a time value from date-time value.
Examples
iex> value = FeelEx.Value.new("08:02:01")
%FeelEx.Value{value: "08:02:01", type: :string}
iex> FeelEx.Functions.time(value)
%FeelEx.Value{value: ~T[08:02:01], type: :time}
iex> value = FeelEx.Value.new("08:02:01+02:00")
%FeelEx.Value{value: "08:02:01+02:00", type: :string}
iex> FeelEx.Functions.time(value)
%FeelEx.Value{value: {~T[08:02:01], "+02:00"}, type: :time}
iex> value = FeelEx.Value.new("08:02:01@Europe/Malta")
%FeelEx.Value{value: "08:02:01@Europe/Malta", type: :string}
iex> FeelEx.Functions.time(value)
%FeelEx.Value{value: {~T[08:02:01], "+01:00", "Europe/Malta"}, type: :time}
iex> value = FeelEx.Value.new(NaiveDateTime.utc_now,"+01:00")
%FeelEx.Value{
value: {~N[2025-01-19 20:50:37.065020], "+01:00"},
type: :date_time
}
iex> value = FeelEx.Value.new(NaiveDateTime.utc_now,"+01:00")
%FeelEx.Value{
value: {~N[2025-01-19 20:50:48.964545], "+01:00"},
type: :date_time
}
iex> FeelEx.Functions.date(value)
%FeelEx.Value{value: ~D[2025-01-19], type: :date}
iex> FeelEx.Functions.time(value)
%FeelEx.Value{value: ~T[20:50:48.964545], type: :time}
Create a FeelEx's time value using hour, minute and second component.
Examples
iex> hour = FeelEx.Value.new(8)
%FeelEx.Value{value: 8, type: :number}
iex> minute = FeelEx.Value.new(16)
%FeelEx.Value{value: 16, type: :number}
iex> second = FeelEx.Value.new(3)
%FeelEx.Value{value: 3, type: :number}
iex> FeelEx.Functions.time(hour,minute,second)
%FeelEx.Value{value: ~T[08:16:03], type: :time}
Create time with hour, minute offset, time and duration FeelEx's components.
Examples
iex> hour = FeelEx.Value.new(8)
%FeelEx.Value{value: 8, type: :number}
iex> minute = FeelEx.Value.new(16)
%FeelEx.Value{value: 16, type: :number}
iex> second = FeelEx.Value.new(3)
%FeelEx.Value{value: 3, type: :number}
iex> duration = FeelEx.Value.new(Duration.new!(hour: 1, minute: 32))
%FeelEx.Value{value: %Duration{hour: 1, minute: 32}, type: :days_time_duration}
iex> FeelEx.Functions.time(hour,minute,second,duration)
%FeelEx.Value{value: {~T[08:16:03], "+01:32"}, type: :time}
Remove leading and trailing spaces from string
Examples
iex> string = FeelEx.Value.new(" Aw Dinja !! ")
%FeelEx.Value{value: " Aw Dinja !! ", type: :string}
iex> FeelEx.Functions.trim(string)
%FeelEx.Value{value: "Aw Dinja !!", type: :string}
Returns a list that includes all elements of the given lists without duplicates.
iex> list = FeelEx.Value.new([[1,2],[3,2]])
[
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number}
],
[
%FeelEx.Value{value: 3, type: :number},
%FeelEx.Value{value: 2, type: :number}
]
]
iex> FeelEx.Functions.union(list)
[
%FeelEx.Value{value: 1, type: :number},
%FeelEx.Value{value: 2, type: :number},
%FeelEx.Value{value: 3, type: :number}
]
Transforms every character in a given string into upper case.
Examples
iex> string = FeelEx.Value.new("Aw dinja !!") %FeelEx.Value{value: "Aw dinja !!", type: :string} iex> FeelEx.Functions.upper_case(string) %FeelEx.Value{value: "AW DINJA !!", type: :string}