Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
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) {
$myxml = simplexml_load_string($response); $qid = $myxml->SignupData['QueryId']; if ($qid == 'camgirls-com') {
$host="mysql.camaffiliate.com"; // Host name $username="camaff"; // Mysql username $password="*********"; // Mysql password $db_name="afftrail"; // Database name $tbl_name="pa_transactions"; // Table name
// Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect 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
If a new client has already been added... then it is not added a 2nd 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
|
|
|
|