11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

return $DEAD # Default.<br />

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

GetCount () # Count live cells in passed cell’s neighborhood.<br />

# Two arguments needed:<br />

# $1) variable hol<strong>di</strong>ng array<br />

# $2) cell number<br />

{<br />

local cell_number=$2<br />

local array<br />

local top<br />

local center<br />

local bottom<br />

local r<br />

local row<br />

local i<br />

local t_top<br />

local t_cen<br />

local t_bot<br />

local count=0<br />

local ROW_NHBD=3<br />

array=( ‘echo "$1"‘ )<br />

let "top = $cell_number - $COLS - 1" # Set up cell neighborhood.<br />

let "center = $cell_number - 1"<br />

let "bottom = $cell_number + $COLS - 1"<br />

let "r = $cell_number / $COLS"<br />

for ((i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!