Skip to content

benpop/lua-range

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python-like range object for Lua.

Has similar semantics to Python's (x)range:

	range(stop)
	range(start, stop)
	range(start, stop, step)

Comes with a Lua implementation that uses a table.

Library functions:
	range() -->  same as range.new()
	new([start, ] stop [, step])  -->  new range object
	bless(table)  -->  (Lua-only) turn table into range object

Methods:
	[Metamethods]
	tostring(obj)  -->  "range(...)"
	#obj  -->  number of items in range
	ipairs(obj)  -->  iterator over range
	obj[index]  -->  same as obj:get(index)

	[Regular methods]
	(The first three are fields in the Lua implementation.)
	start  -->  first number in the range
	stop  -->  last number in the range
	step  -->  interval size of the range
	get(index)  -->  get range item at index
	totable  -->  convert range to a table sequence/list

C source coded for Lua 5.2.

--benpop--

About

Python-like (x)range object for Lua.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published