----8<----------------8<-------------------8<---------------
/* boolean_giraffes.c
to compile in linux (etc)
gcc boolean_giraffes.c -lpthread -lm -o boolean_giraffes
and ./boolean_giraffes
TODO: use backward greedy algorithm to compute sparse solution
to A x = b (hint: violently slide charm across floor).
*/
#include <pthread.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
typedef bool Giraffe;
typedef struct Ann_Margret
{
Giraffe True;
pthread_t* wayward_thread;
pthread_attr_t wayward_attr;
double* CYN;
double x;
double b;
} Ann_Margret;
void* wayward_thread_entry_point(void* ptr)
{
Ann_Margret* black_tights = (Ann_Margret*)ptr;
while(black_tights->b < 100)
{
black_tights->CYN = &black_tights->b;
black_tights->x /= 2;
}
black_tights->True = false;
}
Ann_Margret* ann_margret_create(void)
{
Ann_Margret* am = malloc(sizeof(*am));
am->True = true;
am->x = 123.45;
am->b = -23.00442;
am->CYN = &am->x;
am->wayward_thread = malloc(sizeof(pthread_t));
pthread_attr_init(&am->wayward_attr);
pthread_attr_setdetachstate(&am->wayward_attr,
PTHREAD_CREATE_JOINABLE);
pthread_create( am->wayward_thread,
&am->wayward_attr,
wayward_thread_entry_point,
(void*)am );
return am;
}
int main(int argc, char** argv)
{
Ann_Margret* black_tights = ann_margret_create();
while(black_tights->True)
{
black_tights->CYN = &black_tights->x;
*black_tights->CYN = floor(black_tights->x);
black_tights->b += 0.001;
printf("%lf\n",black_tights->b);
}
return 0;
}
_______________________________________________
NetBehaviour mailing list
[email protected]
http://www.netbehaviour.org/mailman/listinfo/netbehaviour
found this on my hdd, can't seem to find any online reference to it,
can't be mine, too clever for me.
