Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Storing variable coordinates in a matrix

by Moron (Curate)
on Mar 15, 2007 at 17:18 UTC ( [id://605028]=note: print w/replies, xml ) Need Help??


in reply to Storing variable coordinates in a matrix

Hint: you need two nested loops -- nested because of two dimensions x and y -- one loop to clear the 'screen' matrix and one loop to repopulate it and ..."One loop to bring them all and in the darkness run them" ;) (just kidding at the end there)...

Also I'd be expecting to pass five variables to a more generic subroutine -- reference to screen matrix, x, y, width and height rather than hard-code the 3x3.

Totals: 0 modules and about 6 - 12 lines of code should do this.

More hint: the syntax for assigning to an element of a matrix passed by reference would be

$ref -> [$x][$y] = 'X';

-M

Free your mind

Replies are listed 'Best First'.
OT: Re^2: Storing variable coordinates in a matrix
by robot_tourist (Hermit) on Mar 16, 2007 at 12:41 UTC
    One loop to bring them all and in the darkness run them

    You mean TK's mainloop? :)

    How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
    Robot Tourist, by Ten Benson

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://605028]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-03-29 05:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found