Set of real numbers: Difference between revisions

→‎{{header|Wren}}: Now uses new core library method.
(Add Rust version)
(→‎{{header|Wren}}: Now uses new core library method.)
Line 3,482:
{{trans|Kotlin}}
{{libheader|Wren-dynamic}}
{{libheader|Wren-math}}
<lang ecmascript>import "/dynamic" for Enum
import "/math" for Math
 
var RangeType = Enum.create("RangeType", ["CLOSED", "BOTH_OPEN", "LEFT_OPEN", "RIGHT_OPEN"])
Line 3,506 ⟶ 3,504:
union(other) {
if (!other.type == RealSet) Fiber.abort("Argument must be a RealSet")
var low2 = Math_low.min(_low, other.low)
var high2 = Math_high.max(_high, other.high)
return RealSet.new(low2, high2) { |d| _pred.call(d) || other.pred.call(d) }
}
Line 3,513 ⟶ 3,511:
intersect(other) {
if (!other.type == RealSet) Fiber.abort("Argument must be a RealSet")
var low2 = Math_low.max(_low, other.low)
var high2 = Math_high.min(_high, other.high)
return RealSet.new(low2, high2) { |d| _pred.call(d) && other.pred.call(d) }
}
9,486

edits