This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdlib> | |
#include <unistd.h> | |
using namespace std; | |
int main( int argc, char *argv[] ) { | |
int year; | |
int now; | |
char c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PrimeIterator implements Iterator { | |
private $i; | |
private $primes; | |
private function generateNextPrime() { | |
$candidate = $this->primes[ count( $this->primes ) - 1 ]; | |
do { | |
$candidate += 2; | |
$isPrime = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// peano.js - Javascript Peano Arithmetic from thin air | |
// Developer: Dionysis "dionyziz" Zindros <dionyziz@gmail.com> | |
// | |
// This is an illustration of how it is possible to construct the system of arithmetic | |
// on non-negative integers in Javascript without requiring any underlying arithmetic code by the host language. | |
// The system is based purely on the underlying logic of the language; that is, "if", "and", "or", | |
// "not" and the equals operator "==", as well as the logical constants true and false; | |
// those logical constants, incidentally, can be obtained by issuing "null == null" and "!( null == null)" | |
// respectively, so they are not required to be defined. Indeed, observe the following alternative: | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sieve( s ) { | |
if ( s.empty() ) { | |
return s; | |
} | |
var h = s.head(); | |
return new Stream( h, function () { | |
return sieve( s.tail().filter( function ( x ) { | |
return x % h != 0; | |
} ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define( 'N', 10000 ); | |
// upper bound for our prime number | |
$estimate = floor( N * log( N ) + N * log( log( N ) ) ); | |
$primes = array( 2, 3, 5, 7, 11, 13 ); | |
$primeCount = 6; | |
$lastPrime = 13; | |
for ( $i = 17; $primeCount <= N; $i += 2 ) { | |
$prime = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( ( function( f ) { | |
return ( function( x ) { | |
return f( function( n ) { | |
return ( x( x ) )( n ); | |
} ); | |
} )( function( x ) { | |
return f( function( n ) { | |
return ( x( x ) )( n ); | |
} ); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( f = ( x, y, i ) -> if i then f( y, x + y, i - 1 ) else y )( 1, 1, 1475 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int main() { | |
int fd[2]; | |
int a = 0; | |
pipe(fd); | |
if (vfork()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
class Test { | |
private: | |
int foo; | |
public: | |
Test(int foo_value) { | |
foo = foo_value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
class Test { | |
private: | |
int foo; | |
public: | |
Test(int foo_value) { | |
foo = foo_value; | |
} |
OlderNewer