tree: 765defbc531cf0be644991e585990d77e27402cf [path history] [tgz]
  1. adder/
  2. bag/
  3. brutal/
  4. fib/
  5. files/
  6. fizzbuzz/
  7. flip/
  8. hello-world/
  9. iterator/
  10. list/
  11. mapper/
  12. recursive-list-example/
  13. search/
  14. square/
  15. sumofn/
  16. swap-drop/
  17. system-abstract-verif/
  18. template/
  19. .gitignore
  20. README.md
cogent/examples/README.md

Examples in Cogent

A collection of example Cogent programs demonstrating common features in Cogent and how it integrates with non-Cogent code (such as C).

It contains the following examples:

  • hello-world: A very basic “Hello World” example with dedicated comments for new users.
  • adder: Adds two given unsigned 32 bit integers.
  • list: Basic list implementation for unsigned 32 bit integers. Most of the functionality is implemented in antiquoted C as opposed to Cogent to maintain a conventional functional programming style.
  • fizzbuzz: Lists the first 100 integers, except every multiple of 3 is replaced with “Fizz”, every multiple of 5 is replaced with “Buzz” and every multiple of both is replaced with “FizzBuzz”.
  • search: Search on a buffer for a record type element which contains a certain string in a certain field. This example models our pathological case for bad performance -- we cannot directly access contents on the buffer, but have to deserialise them for the sake of linearity.