DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Is A Value Between Two Other Values?

02.28.2006
| 3168 views |
  • submit to reddit
        
between?: func [
    value bound-1 bound-2
    /exclusive
    /local low-bound high-bound
][
    set [low-bound high-bound] sort reduce [bound-1 bound-2]
    either exclusive [
        all [(value > low-bound) (value < high-bound)]
    ][
        ;-- Inclusive comparison
        all [(value >= low-bound) (value <= high-bound)]
    ]
]