Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

How to do this in C?

Name: dddddddddddddddddddd 2007-07-21 5:55 ID:YIX+bdt/

OK guys so I hear C is so awesome how would I do this?

[code]retry action = action `catch` (const $ threadDelay (5*10^6) >> retry action)[code]

basically I want a function that takes an function, executes it, then if it fails it should wait five seconds, repeating this until success

Name: Anonymous 2007-07-21 6:07 ID:VB5Svegx


#include <time.h>
#include <stdio.h>
#include <stdlib.h>

#ifdef WIN32
#include <windows.h>
#define sleep Sleep
#endif

typedef uint8_t fail_func(void);

void retry( fail_func * action )
{
    while( !action() )
    {
        printf( "Failed\n" );
        sleep( 5 );
    }

    printf( "Success\n" );
}

uint8_t some_action(void)
{
    return !( rand() % 10 );
}

int main( int argc, char ** argv )
{
    srand( time( NULL ) );
    retry( some_action );
    return 1;
}

Name: Anonymous 2007-07-21 6:24 ID:Heaven

smaller than your code haskell fag.

for(int(*f)()=fun;f();sleep(5));
btw, i suppose your fun() returns 0 for success.

Name: Anonymous 2007-07-21 7:11 ID:JK3jDiXx

>>2
Sleep() takes milliseconds.

Name: Anonymous 2007-07-21 8:18 ID:Heaven

>>4

You're right. I just wanted it to compile on MingW.

Name: Anonymous 2009-01-14 12:26

LISP

Name: Anonymous 2009-03-06 5:58


reference for that function   with the function   is merely a   collection of exisitng   technologies yet the   marketing put them   like its sum.

Name: ​​​​​​​​​​ 2010-10-24 18:27

Name: Anonymous 2013-08-31 23:04


Formally, the order among cardinal numbers is defined as follows: |X| ≤ |Y| means that there exists an injective function from X to Y. The Cantor–Bernstein–Schroeder theorem states that if |X| ≤ |Y| and |Y| ≤ |X| then |X| = |Y|. The axiom of choice is equivalent to the statement that given two sets X and Y, either |X| ≤ |Y| or |Y| ≤ |X|

Name: Anonymous 2013-08-31 23:49


The infinity symbol \infty (sometimes called the lemniscate) is a mathematical symbol representing the concept of infinity. The symbol is encoded in Unicode at U+221E ∞ infinity (HTML: ∞ &infin;) and in LaTeX as \infty.

Name: Anonymous 2013-09-01 0:34


 In languages that do not provide explicit access to such values from the initial state of the program, but do implement the floating point data type, the infinity values might still be accessible and usable as the result of certain operations.

Name: Anonymous 2013-09-01 1:20


Combinatorial set theory concerns extensions of finite combinatorics to infinite sets. This includes the study of cardinal arithmetic and the study of extensions of Ramsey's theorem such as the Erdős–Rado theorem.

Name: Anonymous 2013-09-01 2:05


A choice function is a function f, defined on a collection X of nonempty sets, such that for every set s in X, f(s) is an element of s. With this concept, the axiom can be stated:

Name: Anonymous 2013-09-01 2:50


In constructive set theory, however, Diaconescu's theorem shows that the axiom of choice implies the Law of excluded middle (unlike in Martin-Löf type theory, where it does not). Thus the axiom of choice is not generally available in constructive set theory.

Don't change these.
Name: Email:
Entire Thread Thread List