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

Use goto

Name: Anonymous 2012-09-17 19:14

I'm using goto outside assembly and there's nothing you can do about it, meanwhile your jewish teachers gave your looping toys and forbid faster code for you.

Name: Anonymous 2012-09-19 3:27

>>31
And a maybe moand is so hard to implement?
You can easily implement it functioanlly with function pointers in c.

Here is a php example which operate on boolean directly, can be used to bind on functions that return a boolean to the maybe monad.
$simpleMaybeMonad = function($f) {
    return $f;   
};

$SMMbind = function($left_monad, $right_monad) use($simpleMaybeMonad) {
    if( $right_monad == false){
        return false;
    }
    else{
        return $simpleMaybeMonad($left_monad);
    }
};

$isTrue = function($abool){
    return $abool==true;   
};


$a1 = $isTrue(true);
$b1 = $isTrue(true);
$c1 = $isTrue(false);

$d = $bind($c1, $bind($a1,$b1));

if( $d == true){
    print("true");   
}
else{
    print("false");   
}


Here is with functions if you want to store functions and call the monad later on.

$maybeMonad = function($f) {
    return array($f, true);   
};

$maybeMonadFunction = function($maybe_a_monad) {
    return $maybe_a_monad[0];
};

$maybeMonadReturnValue = function($maybe_a_monad) {
    return $maybe_a_monad[1];
};

$bind = function($left_monad, $right_monad) use($maybeMonadFunction, $maybeMonad,$maybeMonadReturnValue  ) {
    $resultFunction = $maybeMonadFunction($right_monad);
    $result = $resultFunction();
    if( $maybeMonadReturnValue($right_monad) == false || $result == false){
        return array($maybeMonadFunction($left_monad), false);
    }
    else{
        $left_monad_return = $maybeMonadFunction($left_monad);
        return array( $maybeMonadFunction($left_monad), $left_monad_return() );
    }
};


$isTrue = function($abool){
    return $abool==true;   
};

$a = function()  { return true ; } ;
$b = function()  { return false ; } ;
$c = function()  { return true ; } ;
$aMonad = $maybeMonad($a);
$bMonad = $maybeMonad($b);
$cMonad = $maybeMonad($c);

$dMonad = $bind($cMonad,$bind($aMonad, $bMonad));
if($maybeMonadReturnValue($dMonad) == true){
    print("true");   
}
else{
    print("false");   
}

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