The distance between self and d.

assert 10.distance(15)       ==  5
assert 'Z'.distance('A')         ==  25

Property definitions

core $ Discrete :: distance
	# The distance between self and d.
	#
	#     assert 10.distance(15)	     ==  5
	#     assert 'Z'.distance('A')	     ==  25
	fun distance(d: OTHER): Int
	do
		var cursor: OTHER
		var stop: OTHER
		if self < d then
			cursor = self
			stop = d
		else if self > d then
			cursor = d
			stop = self
		else
			return 0
		end

		var nb = 0
		while cursor < stop do
			cursor = cursor.successor(1)
			nb += 1
		end
		return nb
	end
lib/core/kernel.nit:385,2--409,4

core $ UInt32 :: distance
	redef fun distance(i) do return (self - i).to_i
lib/core/fixed_ints.nit:645,2--48

core $ Int8 :: distance
	redef fun distance(i) do return (self - i).to_i
lib/core/fixed_ints.nit:161,2--48

core $ Int16 :: distance
	redef fun distance(i) do return (self - i).to_i
lib/core/fixed_ints.nit:282,2--48

core $ UInt16 :: distance
	redef fun distance(i) do return (self - i).to_i
lib/core/fixed_ints.nit:403,2--48

core $ Int32 :: distance
	redef fun distance(i) do return (self - i).to_i
lib/core/fixed_ints.nit:524,2--48

core $ Char :: distance
	redef fun distance(c)
	do
		var d = self.code_point - c.code_point
		if d >= 0 then
			return d
		else
			return -d
		end
	end
lib/core/kernel.nit:940,2--948,4

core $ Byte :: distance
	redef fun distance(i) do return (self - i).to_i
lib/core/kernel.nit:658,2--48

gmp $ BigInt :: distance
    #     assert(3.to_bi.distance(6.to_bi) == -3)
    redef fun distance(i) do return (self - i).to_i
lib/gmp/gmp.nit:283,5--284,51

core $ Int :: distance
	redef fun distance(i)
	do
		var d = self - i
		if d >= 0 then
			return d
		else
			return -d
		end
	end
lib/core/kernel.nit:755,2--763,4