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
-------------------------------------------------------------------------------- | |
-- Huffman coding | |
-------------------------------------------------------------------------------- | |
import Data.Maybe | |
import Data.List (nub, sort) | |
data Huffman a = Tip Int a | |
| Node Int (Huffman a) (Huffman a) |
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
-------------------------------------------------------------------------------- | |
-- Checks if there is a high probability of the number being prime using the | |
-- Miller-Rabin primality test | |
-- modPow must be used with the Integer type so that the multiplication won't | |
-- overflow because n could be >= sqrt(maxInt) | |
-------------------------------------------------------------------------------- | |
isPrimeMR :: Int -> Bool | |
isPrimeMR n | |
| n < 2 = False | |
| n /= 2 && n `mod` 2 == 0 = False |
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> | |
#define S(x) char*src=#x;x | |
S(void main(){printf("#include <stdio.h>\n#define S(x) char*src=#x;x\nS(%s)\n",src);}) |
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
-- |3D Vector | |
data Vec3 a | |
= Vec3 { v3x :: a | |
, v3y :: a | |
, v3z :: a | |
} | |
deriving ( Eq, Ord, Show ) | |
-- |Creates a 3D vector |
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
{-# LANGUAGE NamedFieldPuns, RecordWildCards #-} | |
-------------------------------------------------------------------------------- | |
-- OpenGL quadrocopter viewer | |
-------------------------------------------------------------------------------- | |
module Main where | |
import Data.IORef | |
import Control.Monad | |
import Control.Applicative |
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 <stdlib.h> | |
#include <time.h> | |
#include <xmmintrin.h> | |
typedef float __attribute__((aligned(16))) mat4[16]; | |
void | |
mat4_mul_sse(mat4 d, mat4 a, mat4 b) | |
{ |
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
module Main where | |
import Control.Monad | |
table :: [ [ Bool ] ] | |
table | |
= sequence $ replicate 4 [False, True] | |
eval :: [ Bool ] -> [ Bool ] | |
eval [ d, q2, q1, q0 ] |
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
/* Lexer for the mini language */ | |
%lex | |
%% | |
\s+ /* skip whitespace */ | |
"func" return 'FUNC'; | |
"return" return 'RETURN'; | |
"if" return 'IF'; | |
"else" return 'ELSE'; | |
"while" return 'WHILE'; |
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
test: | |
push %rbp | |
mov %rsp, %rbp | |
push %rax # d | |
push %rbx # b | |
push %rcx # c | |
push %rdx # Changed by imul |
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
.text | |
.globl fstrcmp | |
.type fstrcmp, @function | |
fstrcmp: | |
# If the address is already aligned, skip | |
testb $15, %dil | |
jz 1f | |
# If the first string is empty, quit | |
movsbl (%rdi), %edx |
OlderNewer