- GitHub Staff
- @nckrlf
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
-- Compute all n! permutations of a list of n objects | |
-- | |
-- The algorithm is Method 1 from Knuth's The Art of Computer Programming | |
-- Volume 1, Chapter 1, Section 1.2.5 Permutations and Factorials. | |
-- Given an object x and a list of objects ys of length n, insert will return a | |
-- list of n+1 lists by inserting x in all posssible places in ys. | |
-- e.g. insert 1 [2,3,4] returns the following: | |
-- [[1,2,3,4], [2,1,3,4], [2,3,1,4], [2,3,4,1]] |
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
/* A simple dictionary implementation in Rust, using a hash table with | |
* chaining and table doubling. | |
* | |
* Tested with Rust nightly 2014-06-27 | |
*/ | |
extern crate collections; | |
use std::hash; | |
use std::hash::Hash; |
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
// Sample code showing how to create a modern OpenGL window and rendering context on Win32. | |
#include <windows.h> | |
#include <gl/gl.h> | |
#include <stdbool.h> | |
typedef HGLRC WINAPI wglCreateContextAttribsARB_type(HDC hdc, HGLRC hShareContext, | |
const int *attribList); | |
wglCreateContextAttribsARB_type *wglCreateContextAttribsARB; |
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
//---------------------------------------------------------------------- | |
// in opengl.h | |
XX(PFNGLACTIVETEXTUREPROC, glActiveTexture) | |
XX(PFNGLATTACHSHADERPROC, glAttachShader) | |
XX(PFNGLBINDBUFFERPROC, glBindBuffer) | |
// etc. | |
//---------------------------------------------------------------------- | |
// in a C file | |
// Define all the OpenGL function pointers |
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 <stdbool.h> | |
#include <stdio.h> | |
//------------------------------------------------------------------------------ | |
// The code we're testing | |
int add_one(int x) { | |
return x + 1; | |
} | |
int multiply(int x, int y) { |