This file contains hidden or 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
// A primitive compile-time Sieve of Erathostenes, (c) Thomas Lang, 2017 | |
#include <iostream> | |
// First, the usual value-to-type wrapper for usage in type lists. | |
template<unsigned int V> | |
struct Value { | |
enum { value = V }; | |
}; | |
// And the ususal conditional. |
This file contains hidden or 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
// Compile time prime factorization. | |
// (C) Thomas Lang, Aug 6th, 2017 | |
#include <iostream> | |
// First, we create a basic list structure in a functional style: | |
struct NIL { | |
using Head = NIL; | |
using Tail = NIL; | |
}; |
This file contains hidden or 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
# Using defer i.e. calling a function when leaving scope. | |
# Neat trick for cleanup of resources. | |
# | |
# Copyright of lines 5-27 to @briandfoy_perl | |
use v5.10.1; | |
use strict; | |
use warnings FATAL => "all"; | |
sub defer { | |
my ($sub) = @_; |
This file contains hidden or 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
#!/usr/bin/env perl | |
# A simple crawler for getting the nice comics from xkcd.com | |
#(c) Thomas Lang, 2016 | |
# | |
# Yes, this is damn non-performant, but if it works, it ain't stupid. | |
use warnings; | |
use strict; | |
use LWP::Simple; |
This file contains hidden or 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
#!/usr/bin/perl | |
# A damn nice "Conway's game of life". | |
# Taken from 'Coding for fun with Python' and translated into Perl. | |
# | |
# Thomas Lang, (c) 2016. | |
use strict; | |
use warnings; | |
use OpenGL qw/ :all/; |
NewerOlder