Range consolidation: Difference between revisions

→‎{{header|Wren}}: Now uses new core library method.
(Added solution for Action!)
(→‎{{header|Wren}}: Now uses new core library method.)
Line 2,237:
 
=={{header|Wren}}==
{{libheader|Wren-math}}
As Wren already has a built-in Range class (which is not quite the same as what's required here), we create a Span class instead.
<lang ecmascript>importclass "/math"Span for Math{
 
class Span {
construct new(r) {
if (r.type != Range || !r.isInclusive) Fiber.abort("Argument must be an inclusive range.")
Line 2,259 ⟶ 2,256:
if (_high < r.low) return [this, r]
if (r.high < _low) return [r, this]
return [Span.new(Math_low.min(_low, r.low)..Math_high.max(_high, r.high))]
}
 
9,485

edits