This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) | |