Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Great article!

you may be interested in the relationship between programmatic Junctions and Interval Arithmetic ...

a question in our Discord channel asked "why are arithmetic operations on Ranges restricted" with some examples like this:

  (1..2) + 3 => (4..5)   #ok
  (1..2) + (3..4) => 4   #not (4..6)!
to cut a long story short, I made the Math::Interval module to extend the Range class to provide a working Interval Arithmetic model that uses a Junctions of Ranges to represent disjoint results

  # a divisor that spans 0 produces a disjoint multi-interval
  my $j1 = (2..4)/(-2..4);
  ddt $j1;            #any(-Inf..-1.0, 0.5..Inf).Junction
  say 3 ~~ $j1;       #True
(The long story is at https://rakujourney.wordpress.com/2023/11/11/junctions-for-i...)


A good mental tool for thinking about that is adding two dice rolls




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: