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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% Transitioning between steps | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
driver(History, History, (_,_,_,FinalBoard), FinalBoard). | |
driver(History, Trace, State, FinalBoard) :- | |
% print_state(State), | |
step(State, NewState), | |
driver([NewState|History], Trace, NewState, FinalBoard). |
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
% A1 A2 A3 A4 | |
% B1 B2 B3 B4 | |
% C1 C2 C3 C4 | |
% D1 D2 D3 D4 | |
% | |
% Patient is at D1 | |
% Exit is at A4 | |
% | |
% Patient is about to be discharged but wants to visit every other patient | |
% before leaving. Visiting the same patient twice would make him sick. |
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 stack | |
-- stack script --resolver lts-14.7 --package hashable --package hashtables --package vector-sized --package transformers --ghc-options -Wall | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DataKinds #-} | |
module DatalogUnification (main) where | |
import Prelude hiding (fail) | |
import GHC.Generics (Generic) |
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 MinskyGADT where | |
import Data.Array | |
import qualified Data.ByteString as BS | |
import Data.Word (Word8) | |
data GArrayLike a where | |
GArray :: Array Int a -> GArrayLike a | |
GBytes :: BS.ByteString -> GArrayLike Word8 |
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> | |
int main() { | |
char *cptrs[6] = { "hello", "mellow", "yellow" }; | |
char **cptrs2; | |
void **vptrs = (void**) cptrs; | |
vptrs++; | |
cptrs2 = (char**) vptrs; | |
printf("%s\n", *cptrs2); // Prints mellow |
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
def clean_dispatch(&block) | |
b = block.binding | |
locals = b.local_variables | |
params = block.parameters | |
locals.each do |var| | |
b.local_variable_set(var, nil) unless params.include? var | |
end | |
yield |
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
stg_testMezh ( gcptr smt ) | |
{ | |
W_ itbl; | |
W_ ttype; | |
itbl = GET_INFO(UNTAG(smt)); | |
ttype = TO_W_(StgInfoTable_type(itbl)); | |
return (ttype); | |
} |
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
c Bug 1: | |
c Mistakenly initialising unspecified common variable. | |
program nblock | |
integer x, y | |
common /name/x, y | |
call hello | |
call mello | |
print *, x, y | |
end |
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
# PRELUDE: | |
# This is my first biquine. It is between Ruby and Java. | |
# It uses ASCII table to handle issues involving fixed point. | |
# It should work with all versions of Ruby but it definitely works in 2.0 | |
# It should work with all versions of Java and definitely works with 7. | |
# It is not super DRY so it can be refactored to be shorter but 96 lines | |
# is not so bad I guess (I know it is pretty terrible). | |
# Also it is fun to write so if you haven't tried, I highly reccommend it. |
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
# Works on English alphabet with capital letters. | |
# Code with example usage | |
ruby -e "(1..25).each {|i| puts ARGV[0].chars.map {|e| Hash[('A'..'Z').zip(0..25)].invert[(Hash[('A'..'Z').zip(0..25)][e] + i) % 26]}.join('') + %Q|\n\n|}" ESLRPPAKPPFAUWPPKGPPOWPPSJWPPFAUW | |
# Output | |
FTMSQQBLQQGBVXQQLHQQPXQQTKXQQGBVX | |
GUNTRRCMRRHCWYRRMIRRQYRRULYRRHCWY |