sub Func1 {
do we have a num_var;
do we have a name_var;
do we have params (optional)
is the num_var of number format
is the name_var of name format
....
other code
}
Func1($num_var, $name_var, %params);
####
Func1 {
is number of args correct?
check arg1 is a number and only a number with reg exp?
check arg2 is a string and only a string with reg exp?
...
other code
}
####
sub CheckArgs {
get number of args
get args to check
check we have the right number of args
foreach arg check the type with the appropriate reg exp.
return status.
}
sub Func1 {
CheckArgs (2, @_, "NUM", "STRING");
....
other code
}
sub Func2 {
CheckArgs (3, @_, "STRING", "NUM", "STRING");
....
other code
}
####
sub add_output {
#Create an unconnected named output
my $self = shift;
my $graph = $self->{graph};
my $name = shift;
my %params = @_;
#Check for valid options
foreach my $p ( keys %params ) {
if ( !exists $valid_userconfigurable_vertex_params->{$p} ) {
Carp::confess(sprintf "Unknown Option : $p");
}
}
#Set the activation function
my $activation;
if ( exists $params{activation} ) {
$activation = $params{activation};
} else {
$activation = "SIGMOID";
}
#Create the vertex
$graph->set_vertex_attributes($name, { id => GetNewVertexNumber($self),
added_a_vertex => 1,
allow_inputs => "Yes",
allow_outputs => "No",
activation => $activation,
value => 0 });
#Connect vertex to the bias vertex
$graph->add_edge("BIAS", $name);
#An update to the layout is required
$graph->set_graph_attribute("update_layout", 1);
}