XVal examples
Simple calculations
5 + 2 // Result: 7
6 - 3 // Result: 3
12 * 4 // Result: 48
Comparisons
1 = 2 // Result: false
1 <> 2 // Result: true
4 > 5 // Result: false
4 <= 5 // Result: true
Sum a list of numbers
(s:0 -> x+s | x <- [1,2,3,4]) // Result: 10
Return a running sum of numbers
[s:0 -> x+s | x <- [1,2,3,4]] // Result: [1,3,6,10]
Return a running sum of numbers larger than 1
[s:0 -> x+s | x <- [1,2,3,4], x > 1] // Result: [2,5,9]
Pick the last element that matches a condition
Or returns the default state if none is found.
(s:-1 -> x < 3 && x || s | x <- [1,2,3,4]) // Result: 2
Pick elements that match a condition
[x | x <- data, x.Name = ‘A’ || x.Name = ‘C’]
where data = [ { Name:”A”, Value: 1}, { Name: “B”, Value: 2}, { Name: “C”, Value: 3} ]
// Result: [ { Name:”A”, Value: 1}, { Name: “C”, Value: 3} ]
Evaluate to return a value
color: (isRed = 'yes' && 'red') || (isBlue && 'blue') || 'black'
Last updated
Was this helpful?