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
let dqlParser2 = peg("top_level", stack: ParseStack): | |
top_level <- goal * end_marker | |
S <- *Space | |
end_marker <- "." | |
goal <- S * predicate * S * *( separator * S * goal) * *(unary_op) | |
unary_op <- S * "|>" * S * "UN" * S | |
separator <- "," | |
predicate <- named_predicate | selection_stuff | group | |
selection_stuff <- "SEL" | |
group <- "GROUP" |
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
@@grammar::dql | |
############### top markers used by the parser for different contexts | |
start_query | |
= | |
@:top_goal end_marker $ | |
; | |
start_consult |
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
WITH RECURSIVE | |
xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2), | |
yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0), | |
m(iter, cx, cy, x, y) AS ( | |
SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis | |
UNION ALL | |
SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m | |
WHERE (x*x + y*y) < 4.0 AND iter<28 | |
), | |
m2(iter, cx, cy) AS ( |
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
male(terah). | |
male(abraham). | |
male(nahor). | |
male(haran). | |
male(isaac). | |
male(ismael). | |
male(jacob). | |
female(sarah). | |
female(hagar). |
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
curl -L http://tinyurl.com/DanielVim | |
I hereby claim:
- I am reverendpaco on github.
- I am reverend_paco (https://keybase.io/reverend_paco) on keybase.
- I have a public key ASB5p5DKzM53ePcNbBUtjDq-xieXECxljY75e_Dy_z6OTQo
To claim this, I am signing this object:
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
import math | |
def vpcnum(n): | |
Y,X = math.modf( (n-1)/float(16) ) | |
x = "10.{0}.{1}.0".format(int(X),int(Y*256)) | |
return x | |
def client(n): | |
clientNum = (n*2 + 16) | |
return (vpcnum(clientNum-1),vpcnum(clientNum)) |
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
queryNode source node = bool | |
where (bool,_) = queryNodeWithPath source node [] | |
queryNodeWithPath :: (Ord a) => [a] -> TrieNode a -> [[a]] -> (Bool,[[a]]) | |
queryNodeWithPath source@(s:_) node@TrieNode{ nodeType = Top, children=ch} acc | |
| Map.member s ch = queryNodeWithPath source (ch ! s) acc | |
| otherwise = (False,acc) | |
queryNodeWithPath source node@TrieNode{ wordFragment = target, nodeType=nT, children=ch } acc = case matchData of | |
ExactMatchDatum {shared=source} | |
| nT == Word -> (True, (target:acc)) |
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
-- this will be the complicated case | |
insertNode contextNode@TrieNode{children=childNodes,nodeType=oldNodeType} | |
SharedPrefixDatum { shared = sharedPrefix , | |
suffixS = sourceSuffix@(s:ss), | |
suffixT = targetSuffix@(t:ts)} | |
= newForkNode {children = ourTwoNewNodes } | |
where newForkNode = nonWordNode sharedPrefix | |
ourTwoNewNodes = Map.fromList [(s,newSourceSuffixNode),(t,newTargetSuffixNode) ] | |
newSourceSuffixNode = wordNode sourceSuffix | |
newTargetSuffixNode = contextNode{ wordFragment = targetSuffix} |
NewerOlder