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
var inputData = []; | |
var input = 'hi ther'; | |
// Here we will store 8 7bit characters in 7 8bit slots... | |
inputData[0] = input.charCodeAt(0) & ((1 << 7) - 1); | |
inputData[0] = inputData[0] << 1 | input.charCodeAt(1) >> 6; | |
inputData[1] = input.charCodeAt(1) & ((1 << 6) - 1); | |
inputData[1] = inputData[1] << 2 | input.charCodeAt(2) >> 5; |
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
function curry(f, arg) { | |
// Return a new curried function. Mmmm, spicy. | |
return function curriedFunction() { | |
// Take the other arguments and join them with our | |
// curried arg. | |
var args = Array.prototype.slice.call(arguments); | |
args.unshift(arg); | |
// Apply the function. | |
return f.apply(null, args); | |
}; |
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
function compose(g, f) { | |
// Return our composure. | |
return function composedFuction() { | |
var args = Array.prototype.slice.call(arguments); | |
return f.call(null, g.apply(null, args)); | |
}; | |
} |
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
puts 'VTable format' | |
class Array | |
def print_vtable(cols) | |
rows = (self.length.to_f / cols).ceil | |
self.map { |index| | |
x = index % cols | |
y = index / cols | |
x * rows + y |
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
module Main where | |
import Graphics.UI.GLFW | |
import Control.Monad.Cont | |
import System.Exit ( exitSuccess ) | |
main :: IO () | |
main = do | |
putStrLn "Running glfw-cont-test." |
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
module Main where | |
import Graphics.UI.GLFW | |
import Control.Monad.Cont | |
import System.Exit ( exitSuccess ) | |
main :: IO () | |
main = do | |
putStrLn "Running glfw-cont-test." |
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
module Main where | |
import Graphics.UI.GLFW | |
import Control.Monad.Cont | |
import System.Exit ( exitSuccess ) | |
main :: IO () | |
main = do | |
putStrLn "Running glfw-cont-test." |
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
module Main where | |
import Graphics.UI.GLFW | |
import Control.Monad.Cont | |
import System.Exit ( exitSuccess ) | |
data GameState = GameState { keys :: [Key] | |
, wSize:: (Int, Int) | |
, mPos :: (Int, Int) |
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
toTriangleRect :: Rectangle -> [GLfloat] | |
toTriangleRect (Rectangle (x,y) (w,h)) = concat [tl, bl, br, br, tl, tr] | |
where tl = [x,y] | |
tr = [x+w,y] | |
bl = [x,y+h] | |
br = [x+w,y+h] | |
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
module Geometry.Matrix where | |
import Data.List ( intercalate ) | |
import Data.Maybe ( fromJust, fromMaybe ) | |
import qualified Data.List as L | |
{- The Matrix -} | |
type Matrix a = [Vector a] |