Source: https://homepages.loria.fr/GPerrier/courses/M1-progTAL/TP2.pdf