Talang - our lispy rule interpreter at Talon.one
Resolve a template
(! Template1) ; executes the Template1
(! Template2 "Hello World") ; executes Template2 with "Hello World" as parameter
Tests if the arguments are not the same
(!= 1 1) ; compares decimals, returns false
(!= "Hello World" "Hello World") ; compares strings, returns false
(!= true true) ; compares booleans, returns false
(!= 2006-01-02T15:04:05Z 2006-01-02T15:04:05Z) ; compares time, returns false
(!= 1 "1") ; returns false
(!= "Hello" "Bye") ; returns true
(!= "Hello" "Hello" "Bye") ; returns false
Multiplies the arguments
(* 1 2) ; returns 2
(* 1 2 3) ; returns 6
Concat strings
(+ "Hello" " " "World") ; returns "Hello World"
(+ "Hello" " " (toString (+ 1 2))) ; returns "Hello 3"
Adds the arguments
(+ 1 1) ; returns 2
(+ 1 2 3) ; returns 6
Subtracts the arguments
(- 1 1) ; returns 0
(- 1 2 3) ; returns -4
Access a variable in the binding
(. Key1) ; returns the data assigned to Key1
(. Key2 SubKey1) ; returns the data assigned to SubKey1 in the Map Key2
Safe read a binding
.| boo (. List) ; returns "XJK_992" (assuming $List = "XJK_992")
.| boo (. Meh) ; returns "boo" (assuming $Meh is not set)
Divides the arguments
(/ 1 2) ; returns 0.5
(/ 1 2 3) ; returns 0.166666
Tests if the first argument is less then the following
(< 2006-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns true
(< 2007-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns false
(< 2008-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns false
Tests if the first argument is less then the following
(< 0 1) ; returns true
(< 1 1) ; returns false
(< 2 1) ; returns false
Tests if the first argument is less or equal then the following
(<= 0 1) ; returns true
(<= 1 1) ; returns true
(<= 2 1) ; returns false
Tests if the first argument is less or equal then the following
(<= 2006-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns true
(<= 2007-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns true
(<= 2008-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns false
Tests if the arguments are the same
(= 1 1) ; compares decimals, returns true
(= "Hello World" "Hello World") ; compares strings, returns true
(= true true) ; compares booleans, returns true
(= 2006-01-02T15:04:05Z 2006-01-02T15:04:05Z) ; compares time, returns true
(= 1 "1") ; returns true
(= "Hello" "Bye") ; returns false
(= "Hello" "Hello" "Bye") ; returns false
Tests if the first argument is greather then the following
(> 0 1) ; returns false
(> 1 1) ; returns false
(> 2 1) ; returns true
Tests if the first argument is greather then the following
(> 2006-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns false
(> 2007-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns false
(> 2008-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns true
Tests if the first argument is greather or equal then the following
(>= 2006-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns false
(>= 2007-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns true
(>= 2008-01-02T15:04:05Z 2007-01-02T15:04:05Z) ; returns true
Tests if the first argument is greather or equal then the following
(>= 0 1) ; returns false
(>= 1 1) ; returns true
(>= 2 1) ; returns true
Extract days from now from time
(addDuration 2018-03-18T00:04:05Z 3 minutes) ; returns "2018-03-18T00:07:05Z"
(addDuration 2018-03-18T00:04:05Z 2 hours) ; returns "2018-03-18T02:04:05Z"
(addDuration 2018-03-18T00:04:05Z 18 days) ; returns "2018-04-05T00:04:05Z"
Checks whether time A is after B
(after 2006-01-02T19:04:05Z 2006-01-02T15:04:05Z) ; returns "true"
(after 2006-01-01T19:04:05Z 2006-01-02T15:04:05Z) ; returns "false"
Evaluates whether a series of predicates are all true
(and false (> 2 1)) ; returns true
(and false false) ; returns false
Adds an item to the list and returns the list
(append (list "Hello World" "Hello Universe") "Hello Human") ; returns a list containing "Hello World", "Hello Universe" and "Hello Human"
(append (list 1 2) 3 4) ; returns a list containing 1, 2, 3 and 4
Checks whether time A is before B
(before 2006-01-02T19:04:05Z 2006-01-02T15:04:05Z) ; returns "false"
(before 2006-01-01T19:04:05Z 2006-01-02T15:04:05Z) ; returns "true"
Tests if the arguments are between the second last and the last argument
(between 1 0 3) ; returns true, (1 is between 0 and 3)
(between 1 2 0 3) ; returns true, (1 and 2 are between 0 and 3)
(between 0 0 2) ; returns false
(between 2 0 2) ; returns false
(between 1 4 0 3) ; returns false, (1 is between 0 and 3, 4 is not)
Tests if the arguments are between the second last and the last argument
(between 2007-01-02T00:00:00Z 2006-01-02T00:00:00Z 2009-01-02T00:00:00Z) ; returns true, (2007-01-02T00:00:00Z is between 2006-01-02T00:00:00Z and 3)
(between 2007-01-02T00:00:00Z 2008-01-02T00:00:00Z 2006-01-02T00:00:00Z 2009-01-02T00:00:00Z) ; returns true, (2007-01-02T00:00:00Z and 2008-01-02T00:00:00Z are between 2006-01-02T00:00:00Z and 2009-01-02T00:00:00Z)
(between 2006-01-02T00:00:00Z 2006-01-02T00:00:00Z 2008-01-02T00:00:00Z) ; returns false
(between 2008-01-02T00:00:00Z 2006-01-02T00:00:00Z 2008-01-02T00:00:00Z) ; returns false
(between 2007-01-02T00:00:00Z 2010-01-02T00:00:00Z 2006-01-02T00:00:00Z 2009-01-02T00:00:00Z) ; returns false, (2007-01-02T00:00:00Z is between 2006-01-02T00:00:00Z and 2009-01-02T00:00:00Z, 2010-01-02T00:00:00Z is not)
Evaluates whether a timestamp is between minTime and maxTime
(betweenTimes 2006-01-02T19:04:05Z 2006-01-01T15:04:05Z 2006-01-03T19:04:05Z) ; returns "false"
(betweenTimes 2006-01-01T19:04:05Z 2006-01-02T15:04:05Z 2006-01-03T19:04:05Z) ; returns "true"
Evaluate & return the second argument. If any errors occur, return the first argument instead
catch "Edward" (. Profile Name) ; returns "Edward"
catch 22 (. Profile Age) ; returns 46
catch 22 2 ; returns 22
Ceil the decimal argument
(ceil 2) ; returns 2
(ceil 2.4) ; returns 3
(ceil 2.5) ; returns 3
(ceil 2.9) ; returns 3
(ceil -2.7) ; returns -2
(ceil -2) ; returns -2
Concat strings
(+ "Hello" " " "World") ; returns "Hello World"
(+ "Hello" " " (toString (+ 1 2))) ; returns "Hello 3"
Returns wether the first argument exists in the following arguments
(contains "Hello" "Hello World") ; returns true
(contains "Hello" "World") ; returns false
(contains "Hello" "Hello World" "Hello Universe") ; returns true
(contains "World" "Hello World" "Hello Universe") ; returns false
Return the number of items in the input list
(count (list 1 2 3 4)) ; returns "4"
(count (list 1)) ; returns "1"
Extract the date in YYYY-MM-DD format from a time.
(betweenTimes 2006-01-02T19:04:05Z 2006-01-01T15:04:05Z 2006-01-03T19:04:05Z) ; returns "false"
Extract days from now from time
(days 2018-03-18T00:04:05Z) ; returns "3.423892107645601701193527333089150488376617431640625" results vary as the function is relative to the current date.
Calculates the difference in days between 2 dates
daysBetween 2006-01-02T19:04:05Z 2006-01-02T22:19:05Z ; returns "0.13541666666666666"
Apply a block to a value
do (list 1 2 3) ((Item) (. Item))) ; returns 1 2 3
Apply a block to a value
do (list 1 2 3) Item (. Item)) ; returns 1 2 3
Create a list containing all but the last item in the input list
(drop (list "Hello World" "Hello Universe")) ; returns a list containing "Hello World"
(drop (list 1 true Hello)) ; returns a list containing 1 and true
Returns wether the first argument is the suffix of the following arguments
(endsWith "World" "Hello World") ; returns true
(endsWith "World" "Hello Universe") ; returns false
(endsWith "World" "Hello World" "Hello Universe") ; returns false
(endsWith "World" "Hello World" "By World") ; returns true
Test if every item in a list matches a predicate
every (. Items) ((x) (= 1 (. x Price))) ; returns 1 with the right binding in the scope
Test if every item in a list matches a predicate
every (. Items) ((x) (= 1 (. x Price))) ; returns 1 with the right binding in the scope
Test if any item in a list matches a predicate
exists (list hello world) ((Item) (= (. Item) "hello")) ; returns true
exists (list hello world) ((Item) (= (. Item) "hey!!")) ; returns false
Test if any item in a list matches a predicate
exists (list hello world) Item (= (. Item) "hello") ; returns true
exists (list hello world) Item (= (. Item) "hey!!") ; returns false
Create a new list containing items from the input list for which the block evaluates to true
filter (list 1 4 7 12 24 48) ((x) (> (. x) 10)) ; returns "[12 24 48]"
filter (list "Sasquatch" "Front squats" "Caramel" "Cart items") ((x) (contains (. x) "squat")) ; returns "["Sasquatch" "Front squats"]"
Extract all but the last word (space-separated) from a string
(firstName "Alex Unger") ; returns "Alex"
(firstName "Mr Foo Bar") ; returns "Mr"
Floor the decimal argument
(floor 2) ; returns 2
(floor 2.4) ; returns 2
(floor 2.5) ; returns 2
(floor 2.9) ; returns 2
(floor -2.7) ; returns -3
(floor -2) ; returns -2
Create an RFC3339 timestamp, the inverse of parseTime
(formatTime 2018-01-02T19:04:05Z) ; returns "2018"
Returns the first item in the list
(head (list "Hello World" "Hello Universe")) ; returns "Hello World"
(head (list 1 true Hello)) ; returns 1
Extract the hour (00-23) from a time
(hour 2018-01-14T19:04:05Z) ; returns "19"
Check if a list is empty
isEmpty (list hello world) ; returns "false"
isEmpty (list) ; returns "true"
Returns a specific item from a list
(item (list "Hello World" "Hello Universe") 0) ; returns "Hello World"
(item (list 1 true Hello) 1) ; returns true
(item (list 1 true Hello) 3) ; fails
Create a string by joining together a list of strings with glue
(join (list hello world) "-") ; returns "hello-world"
(join (list hello world) ",") ; returns "hello,world"
Create a map with any key value pairs passed as arguments.
(kv (Key1 "Hello World") (Key2 true) (Key3 123)) ; returns a Map with the keys key1, key2, key3
Extract the last word (space-separated) from a string
(lastName "Alex Unger") ; returns "Unger"
(lastName "Mr Foo Bar") ; returns "Bar"
Create a list out of the children
(list "Hello World" "Hello Universe") ; returns a list with string items
(list 1 true Hello) ; returns a list with an int, bool and string
Create a new list by evaluating the given block for each item in the input list
(map (list "World" "Universe") ((x) (+ "Hello " (. x)))) ; returns a list containing "Hello World" and "Hello Universe"
Create a new list by evaluating the given block for each item in the input list
(map (list "World" "Universe") x (+ "Hello " (. x))) ; returns a list containing "Hello World" and "Hello Universe"
Checks if two times match for a given layout
matchTime 2018-03-11T00:04:05Z 2018-03-11T00:04:05Z YYYY-MM-DD ; returns "true"
Find the largest number in the list
(max (list 3 4 1 3 7 1 17 15 2)) ; returns 17
(max (list 4 2 9 2 27 1 2 422)) ; returns 422
Find the lowest number in the list
(min (list 3 4 1 3 7 1 17 15 2)) ; returns 1
(min (list 3 4 -1 3 7 1 17 0 2)) ; returns -1
Extract the hour (00-23) from a time
(minute 2018-01-14T19:04:05Z) ; returns "04"
Modulo the arguments
(mod 1 2) ; returns 1
(mod 3 8 2) ; returns 1
Extract the month (1-12) from a time
(month 2018-01-02T19:04:05Z) ; returns "1"
Extract the day (1-31) from a time
(monthDay 2018-01-14T19:04:05Z) ; returns "14"
No operation
(noop)
Inverts the argument
(not false) ; returns "true"
(not (not false)) ; returns "false"
Returns wether the first argument does not exist in the following arguments
(notContains "Hello" "Hello World") ; returns false
(notContains "Hello" "World") ; returns true
(notContains "Hello" "Hello World" "Hello Universe") ; returns false
(notContains "World" "Hello World" "Hello Universe") ; returns false
Evaluates whether at least one predicate is true
(or false false false true false) ; returns true
(or false false) ; returns false
Evaluates whether a timestamp is between minTime and maxTime
(parseTime "2018-01-02T19:04:05Z") ; returns "2018-01-02 19:04:05 +0000 UTC"
(parseTime "20:04:05Z" "HH:mm:ss") ; returns "2018-01-02 20:04:05 +0000 UTC"
Adds an item to the list and returns the list
(push (list "Hello World" "Hello Universe") "Hello Human") ; returns a list containing "Hello World", "Hello Universe" and "Hello Human"
(push (list 1 2) 3 4) ; returns a list containing 1, 2, 3 and 4
Reverses the order of items in a given list
(reverse (list 1 2 3 4)) ; returns "4 3 2 1"
(reverse (list 1)) ; returns "1"
Set a variable in the binding
(set Key1 "Hello World") ; sets Key1 to "Hello World"
(set Key2 SubKey1 true) ; sets SubKey1 in map Key2 to true
Set a template
(setTemplate "plus(Decimal, Decimal)Decimal" (+ (# 0) (# 1))) ; creates a template with the signature plus(Decimal, Decimal)Decimal
Sort a list ascending, set the second argument to true for descending order
(sort (list "World" "Universe")) ; returns a list containing "Universe" and "World"
(sort (list "World" "Universe") true) ; returns a list containing "World" and "Universe"
Sort a list numerically by value
sortByNumber (list 2 4 3 1) ((Item) (. Item)) true ; returns [4, 3, 2, 1]
sortByNumber (list 2 4 3 1) ((Item) (. Item)) false ; returns [1, 2, 3, 4]
Sort a list alphabetically
sortByString (list "b" "a" "z" "t") ((Item) (. Item)) true ; returns [a, b, t, z]
sortByString (list "b" "a" "z" "t") ((Item) (. Item)) false ; returns [z, t, b, a]
Create a list of strings by splitting the given string at each occurrence of sep
(split "1,2,3,a" ",") ; returns "1 2 3 a"
(split "1-2-3-a" "-") ; returns "1 2 3 a"
Returns wether the first argument is the prefix of the following arguments
(startsWith "Hello" "Hello World") ; returns true
(startsWith "Hello" "World") ; returns false
(startsWith "Hello" "Hello World" "Hello Universe") ; returns true
(startsWith "Hello" "Hello World" "Hell Universe") ; returns false
Extract days from now from time
(subDuration 2018-03-18T00:04:05Z 12 minutes) ; returns "2018-03-17T23:52:05Z"
(subDuration 2018-03-18T00:04:05Z 17 hours) ; returns "2018-03-17T07:04:05Z"
(subDuration 2018-03-18T00:04:05Z 22 days) ; returns "2018-02-24T00:04:05Z"
Test if any item in a list matches a predicate
sum (. List) Item (. Item Price) ; returns 4 With the binding "$Items" containing prices: [2, 2]
Returns list without the first item
(tail (list "Hello World" "Hello Universe")) ; returns a list containing "Hello Universe"
(tail (list 1 true Hello)) ; returns a list containing true and Hello
Converts the parameter to a string
(toString 1) ; returns "1"
(toString true) ; returns "true"
Extract the week day (0-6) from a time
(weekDay 2018-01-14T19:04:05Z) ; returns "3"
Extract the year from a time
(year 2018-01-02T19:04:05Z) ; returns "2018"
Returns wether the first argument (regex) matches all of the following arguments
(~ "[a-z\s]*" "Hello World") ; returns true
(~ "[a-z\s]*" "Hello W0rld") ; returns false
(~ "[a-z\s]*" "Hello World" "Hello Universe") ; returns true
(~ "[a-z\s]*" "Hello W0rld" "Hello Universe") ; returns false