class CIRCS_IN_SQ creation go feature go is local x, y, radius, rscale : REAL i, count : INTEGER rand : STD_RAND pair : GBN_KEYED_PAIR [REAL, GBN_PAIR [REAL,REAL] ] yrad : GBN_PAIR [ REAL, REAL ] heap : GBN_HEAP [ GBN_KEYED_PAIR [REAL, GBN_PAIR[ REAL, REAL] ] ] do -- this part is the nasty part if (argument_count < 1 and argument_count > 3) or else (not argument(1).is_integer) or else (argument_count >= 2 and then not argument(2).is_real) or else (argument_count = 3 and then not argument(3).is_integer) then std_error.put_string(argument(0) + " expects integer args: count, optional scale, optional seed%N") else count := argument(1).to_integer if argument_count >= 2 then rscale := argument(2).to_real.abs else rscale := 0.05 end if argument_count = 3 then !! rand . with_seed ( argument(3).to_integer ) else !! rand . make end -- this part is the nice part !! heap . make from i := 1 until i > count loop rand . next x := rand . last_real rand . next y := rand . last_real rand . next radius := rand . last_real * rscale !! pair . make ( x ) !! yrad . make ( y, radius ) pair . put ( yrad ) heap . add ( pair, Void ) i := i + 1 end from io . put_integer ( heap.count ) io . put_new_line until heap . is_empty loop pair := heap . min io . put_real ( pair . key ) io . put_character (' ') io . put_real ( pair . item . x ) io . put_character (' ') io . put_real ( pair . item . y ) io . put_new_line heap . delete_min end end -- if valid arguments end -- routine go end -- class CIRCS_IN_SQ