General purpose algorithms written using the Swift language