First class environments

From Rosetta Code
Revision as of 08:53, 30 June 2011 by rosettacode>Abu (Created draft task)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
First class environments is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

A first class environment is a set of variable bindings which can be stored in variables, passed to functions, compared, etc.

The task is to build a dozen environments, and a single piece of code to be run repeatedly in each of these envionments.

Each environment contains the bindings for two variables: A value in the Hailstone sequence, and a count which is incremented until the value drops to 1. The initial hailstone values are 1 through 12, and the count in each environment is zero.

When the code runs, it calculates the next hailstone step in the current environment (unless the value is already 1) and counts the steps. Then it prints the current value in a tabular form.

When all hailstone values dropped to 1, processing stops, and the total number of hailstone steps for each environment is printed.