Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Mars0i
On Thursday, July 21, 2016 at 8:50:21 AM UTC-5, miner wrote: > > With a little help from Java, you can make equivalent open intervals for > the desired bounds. For example, > > Also, you can use java.lang.Math/nextUp and nextAfter to get adjacent > doubles for your bounds. > > (java.lang.Math/

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Steve Miner
> (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %)) > > should be the same as > > (s/double-in :min Double/MIN_VALUE :max 1.0) I should have mentioned that Double/MIN_VALUE is the smallest positive double (just greater than 0.0), not a large negative value. It’s easy to get confused

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Mars0i
On Thursday, July 21, 2016 at 9:51:02 AM UTC-5, Alex Miller wrote: > > You can already get open intervals by just omitting :min or :max. > I think my terminology may have created some confusion; I probably shouldn't have used open/closed. I meant "open interval" in the sense that an open interv

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Alex Miller
You can already get open intervals by just omitting :min or :max. On Thursday, July 21, 2016 at 8:50:21 AM UTC-5, miner wrote: > > With a little help from Java, you can make equivalent open intervals for > the desired bounds. For example, > > (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Steve Miner
With a little help from Java, you can make equivalent open intervals for the desired bounds. For example, (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %)) should be the same as (s/double-in :min Double/MIN_VALUE :max 1.0) Also, you can use java.lang.Math/nextUp and nextAfter to get a

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-20 Thread Mars0i
On Wednesday, July 20, 2016 at 10:02:17 PM UTC-5, Alex Miller wrote: > > On Wednesday, July 20, 2016 at 9:41:59 PM UTC-5, Mars0i wrote: >> >> On Wednesday, July 20, 2016 at 4:32:40 PM UTC-5, Alex Miller wrote: >>> >>> You can file a jira if you like, I'm not sure Rich's thoughts on this. >>> >>

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-20 Thread Alex Miller
On Wednesday, July 20, 2016 at 9:41:59 PM UTC-5, Mars0i wrote: > > On Wednesday, July 20, 2016 at 4:32:40 PM UTC-5, Alex Miller wrote: >> >> You can file a jira if you like, I'm not sure Rich's thoughts on this. >> > > I understand. Thanks--will do. > > >> Also, keep in mind that you can also

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-20 Thread Mars0i
On Wednesday, July 20, 2016 at 4:32:40 PM UTC-5, Alex Miller wrote: > > You can file a jira if you like, I'm not sure Rich's thoughts on this. > I understand. Thanks--will do. > Also, keep in mind that you can also compose preds and get this with > slightly more effort now: > > (s/and (s/dou

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-20 Thread Alex Miller
You can file a jira if you like, I'm not sure Rich's thoughts on this. Also, keep in mind that you can also compose preds and get this with slightly more effort now: (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %)) On Wednesday, July 20, 2016 at 2:03:28 PM UTC-5, Mars0i wrote: > > cloj

Enhance spec/double-in to handle open and half-open intervals?

2016-07-20 Thread Mars0i
clojure.spec/double-in defines a spec that tests whether a double is greater than or equal to a minimum value and less than or equal to a maximum value. This is useful for many purposes, but sometimes you need to test whether a double is greater than a minimum or less than a maximum. There ar