Relate intervals with Rampart

栏目: IT技术 · 发布时间: 6年前

内容简介:Have you ever needed to know if two intervals overlap? I wroteThe other day at work we were working on a system that needed to select accounts that were active during a certain timeframe. This seemingly simple problem prompted a bunch of discussion. We spe

Have you ever needed to know if two intervals overlap? I wrote Rampart , a small Haskell library to help with that.

The other day at work we were working on a system that needed to select accounts that were active during a certain timeframe. This seemingly simple problem prompted a bunch of discussion. We spent some time puzzling through inequalities before we landed on something that everyone agreed would do what we wanted. I figured we could save ourselves and others time in the future by making a library to handle the tricky interval logic.

You may be thinking that this is a trivial problem. Did you know that there are 13 different ways that two intervals can relate to each other? Here they are:

Relate intervals with Rampart

Rampart is a tiny Haskell module that can take two intervals and tell you how they relate. For example, how does the interval from 2 to 4 relate to the interval from 3 to 5?

>>> import Rampart
>>> relate (toInterval (2, 4)) (toInterval (3, 5))
Overlaps

It’s easy to show off with numbers, but it works with anything that’s orderable: dates, times, money, and so on. So if you find yourself asking questions about intervals, consider using Rampart to answer them.

You can find the documentation here: https://hackage.haskell.org/package/rampart-1.0.0.1/docs/Rampart.html .


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

社会工程

社会工程

海德纳吉 (Christopher Hadnagy) / 陆道宏、杜娟、邱璟 / 人民邮电出版社 / 2013-12 / 59.00元

本书首次从技术层面剖析和解密社会工程手法,从攻击者的视角详细介绍了社会工程的所有方面,包括诱导、伪装、心理影响和人际操纵等,并通过凯文 · 米特尼克等社会工程大师的真实故事和案例加以阐释,探讨了社会工程的奥秘。主要内容包括黑客、间谍和骗子所使用的欺骗手法,以及防止社会工程威胁的关键步骤。 本书适用于社会工程师、对社会工程及信息安全感兴趣的人。一起来看看 《社会工程》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具