blob: 548845b9674fff8dad5e035aa807870f89284c44 [file] [log] [blame] [view]
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01001[TOC](Readme.md) [Prev](numbers.md) [Next](rangedef.md)
2
Marcel van Lohuizen3e592b42019-01-11 20:31:29 +01003_Types ~~and~~ are Values_
Marcel van Lohuizenaf0932f2019-01-11 13:03:56 +01004
Marcel van Lohuizen62b87272019-02-01 10:07:49 +01005# Bounds
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01006
Marcel van Lohuizen62b87272019-02-01 10:07:49 +01007Bounds define a lower bound, upper bound, or inequality for a certain value.
8They work on numbers, strings, bytes, and and null.
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01009
Marcel van Lohuizen62b87272019-02-01 10:07:49 +010010The bound is defined for all values for which the corresponding comparison
11operation is define.
12For instance `>5.0` allows all floating point values greater than `5.0`,
13whereas `<0` allows all negative numbers (int or float).
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010014
15<!-- CUE editor -->
16```
Marcel van Lohuizen62b87272019-02-01 10:07:49 +010017rn: >=3 & <8 // type int | float
18ri: >=3 & <8 & int // type int
19rf: >=3 & <=8.0 // type float
20rs: >="a" & <"mo"
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010021
22{
23 a: rn & 3.5
24 b: ri & 3.5
25 c: rf & 3
Marcel van Lohuizene71fec62019-01-30 21:28:32 +010026 d: rs & "ma"
27 e: rs & "mu"
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010028
Marcel van Lohuizen62b87272019-02-01 10:07:49 +010029 r1: rn & >=5 & <10
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010030}
31```
32
33<!-- result -->
34```
35a: 3.5
36b: _|_
Marcel van Lohuizene71fec62019-01-30 21:28:32 +010037c: 3.0
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010038d: "ma"
39e: _|_
Marcel van Lohuizen62b87272019-02-01 10:07:49 +010040r1: >=5 & <8
Jonathan Amsterdame4790382019-01-20 10:29:29 -050041```