ComputerCraft Archive

array

computer utility kepler155c github

Description

ComputerCraft OS

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/modules/opus/array.lua array
Archive:wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-modules-opus-array array
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-modules-opus-array array

Usage

Run: array

Tags

none

Source

View Original Source

Code Preview

local Util = require('opus.util')

local Array = { }

function Array.filter(it, f)
	local ot = { }
	for _,v in pairs(it) do
		if f(v) then
			table.insert(ot, v)
		end
	end
	return ot
end

function Array.removeByValue(t, e)
	for k,v in pairs(t) do
		if v == e then
			table.remove(t, k)
			return e
		end
	end
end

Array.find = Util.find

return Array