> For the complete documentation index, see [llms.txt](https://keli-language.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://keli-language.gitbook.io/doc/blog/interval-comparison-operator-for-free.md).

# Interval comparison operator for free!

### Introduction

If you had used Python before, you might have encountered a syntax sugar so called the Interval Comparison Operator, which is very convenient for checking if an integer is within a specific range.

For example,

```python
if 80 <= grade <= 100:
    print("You got A!")
else:
    print("Sorry, not A ...")
```

This is one of the nicest feature that Python has, however, it is not possible to be implemented in other language without performing some macro magic or modifying the internal parser.&#x20;

But guess what? You can have that for free in Keli!

Because those operators can be defined as usual functions, as follows:

```c
// Definition
(a Int).<=(b Int)<=(c Int) = 
    a.<=(b).and(b.<=(c))

// Usage
= 80.<=(90)<=(100)
```

Moreover, it also works with Keli's Intellisense!&#x20;

![](/files/-L_b1sX5n3z3w31-ucNT)

### How is this possible?&#x20;

This is possible because Keli supports the following features:

1. Keyword message syntax (like Smalltalk)
2. Function name can be any combination of operators

### Conclusion

Of course, there are still a lot of other domain-specific operators or functions that can be defined easily in Keli. Hope you like this article, and is able to leverage the power of Keli to create your own domain-specific language(DSL) without hassle.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://keli-language.gitbook.io/doc/blog/interval-comparison-operator-for-free.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
