Example Cool Programs

May 26, 2016 ยท View on GitHub

The examples directory contains a few small and not so small example programs which illustrate various aspects of the Cool programming language.

PROGRAMDESCRIPTION
arith.clTests various aspects of arithmetic in Cool.
atoi.clAn implementation of the C function by the same name. It converts a String into an Int.
atoi_test.clAn example program using atoi.cl.
list.clA very simple program showing how to create a list data type for integers. It illustrates inheritance and dynamic dispatch.
book_list.clIllustrates inheritance and in particular the mechanism of STATIC DISPATCH and the CASE statement.
cells.clModels a one-dimensional cellular automaton.
cool.clAn short and obscure program.
io.clShows how to use the IO class. (input/output).
hairyscary.clExercises many of the obscure features of the language in obscure ways.
hello_world.clThe classic first program.
primes.clAn unusual prime number generator.
graph.clA program reading descriptions of weighted-directed graphs from stdin in text format.
g1.graph.txtA sample input to graph.cl.
palindrome.clRecognizes palindromes.
complex.clChecks the = operator and cummulative effects of method calls via a complex number object.
life.clThe classic Game of Life.
sort_list.clA more complex example sorting lists of integers.

The credits of writing these example programs go to the Stanford teaching comittee and Professor Alex Aiken who shared these programs for educational purposes via the Compilers Theory Coursera course.