~singpolyma/dhall-ruby

b42429330df3fca2f827ebda420c648b29c341bd — Stephen Paul Weber 5 years ago 06fb351
Simplify Natural/subtract on x === y
2 files changed, 8 insertions(+), 5 deletions(-)

M dhall-lang
M lib/dhall/builtins.rb
M dhall-lang => dhall-lang +1 -1
@@ 1,1 1,1 @@
Subproject commit 1ed98c33ce5078161109885f0b16b3828958f4e2
Subproject commit fd39a0d6db4a276cbdd6ab1f14b58c8330ad88da

M lib/dhall/builtins.rb => lib/dhall/builtins.rb +7 -4
@@ 102,10 102,9 @@ module Dhall
			protected

			def uncurried_call(x, y)
				if Natural_isZero.new.call(x) === true ||
				   Natural_isZero.new.call(y) === true
					return y
				end
				return y if zero?(x) || zero?(y)

				return Dhall::Natural.new(value: 0) if x == y

				unless x.is_a?(Dhall::Natural) && y.is_a?(Dhall::Natural)
					return unfill(x, y)


@@ 113,6 112,10 @@ module Dhall

				Dhall::Natural.new(value: [y.to_i - x.to_i, 0].max)
			end

			def zero?(x)
				Natural_isZero.new.call(x) === true
			end
		end

		class Natural_even < BuiltinFunction