Skip to content

Instantly share code, notes, and snippets.

View olabini's full-sized avatar

Ola Bini olabini

View GitHub Profile
GameOfLife = Origin mimic do(
initialize = method(rows:, columns:,
@grid = Grid withDimensions(rows, columns))
evolve = method(
nextGrid = grid blankGrid
grid filter(numLiveNeighbours in?(2..3)) each(cellInfo, nextGrid spawnCell(cellInfo coords first, cellInfo coords second))
@grid = nextGrid
)
counts = method(
files_to_read = FileSystem["**"] reject(name, FileSystem directory?(name))
combined_text = files_to_read map(filename, FileSystem readFully(filename)) join("")
filtered_words = #/\w+/ allMatches(combined_text) map(lower)
filtered_words inject({} withDefault(0), counts, word, counts[word]++. counts)
)
spit = method(outfile, enumerable,
FileSystem withOpenFile(outfile, fn(file, enumerable each(x, file println(x)))))