Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: The MYTH of UNCOMPUTABLE FUNCTIONS
Replies: 1   Last Post: Jan 13, 2013 3:04 PM

 Graham Cooper Posts: 4,495 Registered: 5/20/10
Re: The MYTH of UNCOMPUTABLE FUNCTIONS
Posted: Jan 13, 2013 3:04 PM

On Jan 13, 7:30 pm, Rupert <rupertmccal...@yahoo.com> wrote:
> On Saturday, January 12, 2013 10:48:43 PM UTC+1, Graham Cooper wrote:
> > Turing's Halt Proof clearly proves that
>
> > HALT( program, input )  --> [yes/no]
>
> > is not a PURE FUNCTION!
>
> How do you define "pure function"?
>

the output is determined by the input alone

Here is a function that imports CAMGIRLS Sales data to the AFFILIATE
PROGRAM

function(\$result)
{

\$qid = \$myxml->SignupData['QueryId'];
if (\$qid == 'camgirls-com') {

\$host="mysql.camaffiliate.com"; // Host name
\$db_name="afftrail"; // Database name
\$tbl_name="pa_transactions"; // Table name

// Connect to server and select database.
to server ");
mysql_select_db("\$db_name")or die("cannot select DB");

\$assets = \$myxml->SignupData;
\$html = '<ul>'."\n";
foreach (\$assets->Data as \$asset) {
\$html .= '<li>' . \$asset['SignupTime'] . ' ' .
\$asset['TrackingID'] . ' ' . \$asset['UserID'] . '</li>' . "\n";
\$sut = \$asset['SignupTime'];
\$tid = \$asset['TrackingID'];
\$uid = \$asset['UserID'];

\$sql="SELECT * FROM \$tbl_name WHERE transid=" . \$uid;
\$result=mysql_query(\$sql);
\$rows=mysql_fetch_array(\$result);
\$userthere=\$rows['transid'];

// if table has no UserID value
if(empty(\$userthere)){

\$sql1="INSERT INTO \$tbl_name(transid, dateinserted, totalcost,
affiliateid) VALUES('\$uid','\$sut',80,'\$tid')";
\$result1=mysql_query(\$sql1);

}

}//end foreach

\$html .= '</ul>'."\n";
// echo \$html;

mysql_close();
}

But the results of the function are not determined only by the input

time!

// if table has no UserID value
if(empty(\$userthere)){

*********************************

You can CHANGE a function with global variables and side effects into
a PURE FUNCTION

by adding more parameters into the parameter list.

Herc