<commit_before>_length = std.object { 
	length = 0, 
	stretch = 0, 
	shrink = 0, 
	_type = "Length",
	fromLengthOrNumber = function (self, x)
		if type(x) == "table" then
			self.length = x.length
			self.stretch = x.stretch
			self.shrink = x.shrink
		else
			self.length = x
		end
		return self
	end,
	__tonumber = function(self)
		if not(self.stretch ==0) or not(self.shrink == 0) then
			SU.warn("tonumber called on a glue length. Bug?")
		end
		return self.length
	end,
	__tostring = function (x)	
		local s = tostring(x.length).."pt"
		if not (x.stretch == 0) then s = s .. " plus "..x.stretch.."pt" end
		if not (x.shrink == 0) then s = s .. " minus "..x.shrink.."pt" end
		return s
	end,
	__add = function (self, other)
		local n = _length {}
		n:fromLengthOrNumber(self)
		if type(other) == "table" then
			n.length = n.length + other.length
			n.stretch = n.stretch + other.stretch
			n.shrink = n.shrink + other.shrink
		else
			n.length = n.length + other
		end
		return n
	end,
	__sub = function (self, other)
		local n = _length {}
		n:fromLengthOrNumber(self)
		if type(other) == "table" then
			n.length = n.length - other.length
			n.stretch = n.stretch - other.stretch
			n.shrink = n.shrink - other.shrink
		else
			n.length = n.length - other
		end
		return n
	end,
	__lt = function (self, other) return (self-other).length < 0 end,
}

length = { new = function (spec) return _length(spec or {}) end }
return length<commit_msg>Zero length might be helpful for settings.<commit_after>_length = std.object { 
	length = 0, 
	stretch = 0, 
	shrink = 0, 
	_type = "Length",
	fromLengthOrNumber = function (self, x)
		if type(x) == "table" then
			self.length = x.length
			self.stretch = x.stretch
			self.shrink = x.shrink
		else
			self.length = x
		end
		return self
	end,
	__tonumber = function(self)
		if not(self.stretch ==0) or not(self.shrink == 0) then
			SU.warn("tonumber called on a glue length. Bug?")
		end
		return self.length
	end,
	__tostring = function (x)	
		local s = tostring(x.length).."pt"
		if not (x.stretch == 0) then s = s .. " plus "..x.stretch.."pt" end
		if not (x.shrink == 0) then s = s .. " minus "..x.shrink.."pt" end
		return s
	end,
	__add = function (self, other)
		local n = _length {}
		n:fromLengthOrNumber(self)
		if type(other) == "table" then
			n.length = n.length + other.length
			n.stretch = n.stretch + other.stretch
			n.shrink = n.shrink + other.shrink
		else
			n.length = n.length + other
		end
		return n
	end,
	__sub = function (self, other)
		local n = _length {}
		n:fromLengthOrNumber(self)
		if type(other) == "table" then
			n.length = n.length - other.length
			n.stretch = n.stretch - other.stretch
			n.shrink = n.shrink - other.shrink
		else
			n.length = n.length - other
		end
		return n
	end,
	__lt = function (self, other) return (self-other).length < 0 end,
}

local zero = _length({})
length = { 
	new = function (spec) return _length(spec or {}) end,
	zero = zero 
}
return length
{'fraction_non_alphanumeric': 0.13693086003372681, 'fraction_numerical': 0.005396290050590219, 'mean_word_length': 2.8369987063389392, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4352688', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1120, 'n_words': 322}