Real.ordered? 🤘


I was just admiring some of the craftsmanship in the latest drop! This one stuck out first as a “wait, huh?” moment that later turned into a smile when it clicked.

({Real} nums) Boolean
  [nums.length <= 1] // treat 0 and 1 item as ordered
    !prev: nums.first!
    nums.all?[[prev <= item] and [prev := item true]]



Half the reason why that method was added was to be an example. :madsci:

For anyone who is curious what we are talking about, this is the Real.ordered?() method. It determines if all the supplied numbers (num1 <= num2 <= … <= numN) are in order and returns true or false.

For example:

if Real.ordered?(num1 num2 num3 num4)