Io Exercises

Author: Nicolaas A. Scheltens

CPS 499-03: Emerging Languages, Spring 2017

  1. Create a prototype that reads a string of numbers from standard input and transforms that string into a list of numbers. Create an exponent slot that accepts two integers as input and returns the first number raised to the second number power. Send the exponent message to every integer in the newly-created list using the last integer as the exponent and print the modified list.

    Examples:
    Io> 1 2 3 4 5 2
    ==> list(1, 4, 9, 25)
    Io> 2 3 7 1 5 3
    ==> list(16, 81, 2401, 1, 625)
    
  2. Use coroutines and the Actor model to create a synchronization barrier. Read the number of workers to be spawned as well as the capacity of the barrier as an integer from standard input. The barrier must wait for all workers to arrive before allowing any workers through the barrier.

    Examples:
    Io> 3
    Started a worker.
    Started a worker.
    Started a worker.
    Worker2 has arrived at the barrier.
    Worker1 has arrived at the barrier.
    Worker3 has arrived at the barrier.
    Worker2 is through the barrier.
    Worker1 is through the barrier.
    Worker3 is through the barrier.