Exercises

  1. Write a procedure called bc which evaluates an arbitrary precision arithmetic expression (see page 229). The procedure should pass it to a bc process that has already been spawned and return the result so that it can used with other Tcl commands. For example:

    set foo [bc 9487294387234/sqrt(394872394879847293847)]

  2. Modify the chess script so that it keeps track of the time spent by each player and optionally halts the game if either player exceeds a time limit.

  3. Named pipes allow unrelated processes to communicate. Write a script that creates a named pipe and writes a chess move to it. Write another script that opens the other end of the pipe and reads a chess move from it. Create another pipe so the scripts can communicate in the other direction as well.

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.