The Basics of Big O Notation

Big O notation expresses how an algorithm grows relative to the input and extrapolates the input out to something arbitrarily large or even infinity. This gives us how long an algorithm takes to run in best case and worst case scenarios.

This isn’t going to tell us exactly how long it takes to run an algorithm (for reasons we’ll get into in a bit), but gives a way to rank and compare algorithms as a whole, and gives you a scale of how big it will be.… Read the rest

Expanding Lua Functions

This article is an extension of our previous article on functions. We’re going to learn a few new tricks and see how they can be applied. It also will expand on classes just a little bit.

We’re going to cover passing a variable number of arguments to a function, and how to use functions as variables. Lua has a special construction for passing an arbitrary number of functions without using a table as: an array or a hash table (both are technically tables).… Read the rest

The Quick Guide to Understanding Quicksort

Quicksort is one of the most popular algorithms to sort with. It’s average use case is great, it’s relatively easy to implement, and it’s worst case isn’t that easy to stumble into. We’ll go over how it’s actually implemented and what can be done better with it.

Introducing Quicksort

Quicksort is a divide and conquer algorithm. It works by splitting the data set into increasingly smaller sets and recursively iterating over them until there’s nothing left.… Read the rest

Data Munging: Reverse Engineering a Format

Data munging is the practice of taking data from one format and converting it into another format programmatically. Data munging is extremely important for working with logs and esoteric data formats. It’s a useful skill from basic systems automation to more specific fields like GIS or even financial positions.

We’re going to cover the basics of how to approach data munging, how to look at and think about the reverse engineering process, and a few examples with Lua using real data formats.… Read the rest

Lua String Operations

Let’s get into the string operations in Lua. Lua offers a wide range of functions for working with text. As we mentioned earlier, Lua is Unicode agnostic. Unicode agnostic is good enough for most things, but there are situations where this just doesn’t work, so we’ll introduce a library for working with utf8 in Lua as well. Let’s go over the basic string operations first.… Read the rest

Using JSON With Lua

We’ve worked with basic file operations and covered the basics of JSON as well. Let’s learn how to put them together.

There are many JSON libraries available for Lua, but I true to stick with pure Lua libraries unless I really need the extra performance. If you notice your application running slow or similar, you may look for C libraries with bindings in Lua.… Read the rest