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
| #include <iostream> | |
| #include <fstream> | |
| #include <cstdio> | |
| #include <cassert> | |
| #define TAPE_SIZE 20000 | |
| static unsigned char tape[TAPE_SIZE] = {0}; | |
| static unsigned char *ptr = tape; |
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
| #!/bin/bash | |
| test=test_${1%.*} | |
| qtest -o $test.ml extract $1 | |
| ocamlbuild -cflags -warn-error,+26 -use-ocamlfind -pkg oUnit,QTest2Lib $test.native | |
| ./$test.native | |
| rm -f qtest.targets.log $test.ml $test.native | |
| rm -rf _build |
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
| #include <stdio.h> | |
| #define concat_(x, y) x##y | |
| #define concat(x, y) concat_(x, y) | |
| #define add_int(hd, val) \ | |
| node_t concat(hd_, __LINE__) = { .i = val, INT, hd }; \ | |
| hd = &concat(hd_, __LINE__) | |
| #define add_float(hd, val) \ |
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
| #!/bin/sh | |
| if [ -f .merlin ]; then | |
| echo ".merlin already exists" | |
| read -p "Overwrite? (y/n) " -n 1 | |
| echo | |
| if [[ $REPLY =~ [Nn] ]]; then | |
| echo "Okay, bye." | |
| exit 1 | |
| fi |
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
| twice f = f . f | |
| n `times` f = if n > 0 then f . ((n-1) `times` f) else id |
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
| import Control.Monad (guard) | |
| carnac :: [String] | |
| carnac = do | |
| o1 <- ops | |
| o2 <- ops | |
| o3 <- ops | |
| o4 <- ops | |
| o5 <- ops | |
| o6 <- ops |
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
| import Control.Monad (guard, mfilter) | |
| import Control.Monad.Trans.State | |
| import Data.List (foldl') | |
| select :: [a] -> [(a, [a])] | |
| select [] = [] | |
| select (x:xs) = (x,xs) : [(y,x:ys) | (y,ys) <- select xs] | |
| -- StateT select :: StateT [a] [] a |
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
| import System.Environment | |
| import Data.List (foldl', intercalate) | |
| import Data.List.Split (splitOn) | |
| addTo :: Num a => [a] -> [a] -> [a] | |
| addTo [] values = values | |
| addTo totals values | |
| | length values == length totals = zipWith (+) values totals | |
| | otherwise = error "Inconsistent number of fields" |
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
| fun toReal str = | |
| case Real.fromString str of | |
| SOME r => r | |
| | NONE => raise Fail ("Invalid number: " ^ str) | |
| fun split line delim = String.tokens (fn c => c = delim) line | |
| fun foldS f acc stream = | |
| case TextIO.inputLine stream of | |
| SOME line => foldS f (f (acc, line)) stream |
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
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <pthread.h> | |
| struct handler_stats { | |
| int x, y; | |
| }; | |
| static void *handler(void *args) | |
| { |