1 point by yimingchen 3 days ago | flag | 1 comment
yimingchen 3 days ago | flag

The comment in the code


table Ranges = with 
  [| date(2010, 01, 03) as Start, date(2010, 10, 12) as End |]
  [| date(2011, 07, 23)         , date(2012, 03, 01)        |]
  [| date(2010, 09, 27)         , date(2011, 05, 31)        |]
 
Ranges.Collision = for Start in Ranges.Start, 
                       End   in Ranges.End
 
  // (true, false, false) on the 1st iteration,
  // (false, true, false) on the 2nd,
  // (false, false, true) on the 3rd  
  Ranges.NotSameRange = (Start != Ranges.Start or End != Ranges.End)
 
  // (true, false, true)  on the 1st iteration,
  // (false, true, false) on the 2nd iteration, 
  // (true, false, true)  on the 3rd iteration
  Ranges.Intersects = max(Start, Ranges.Start) <= min(End, Ranges.End)
 
  // true  on the 1st iteration,
  // false on the 2nd iteration,
  // true  on the 3rd iteration
  return any(Ranges.NotSameRange and Ranges.Intersects)
 
show table "Ranges" with
  Ranges.Start
  Ranges.End 
  Ranges.Collision // (true, false, true)

should be


  // (false, true, true) on the 1st iteration,
  // (true, false, true) on the 2nd,
  // (true, true, false) on the 3rd  
  Ranges.NotSameRange = (Start != Ranges.Start or End != Ranges.End)