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
type ProcNum = Int | |
type Sort = String | |
data Op = And | Or deriving (Show,Eq) | |
data Ex = Proc Sort ProcNum | BoolOp Op Ex Ex | Not Ex | |
instance Show Ex where | |
show (BoolOp op a b) = "("++show a++" "++show op++" "++show b++")" | |
show (Proc name n) = name++show n | |
show (Not e) = '!':show e |
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
#const n=5. | |
#const k=3. | |
num(1..n). | |
ens(1..k). | |
1{dans(N,E) : ens(E)}1 :- num(N). | |
:- dans(N,E), dans(M,E), dans(M+N,E). | |
#show dans/2. |
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 <vector> | |
#include <string> | |
using namespace std; | |
class Proc { | |
public: | |
string name; | |
int num; | |
Proc(string nm, int n) : name(nm), num(n) {}; |
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
fn join<S:ToString> (l: Vec<S>, sep: &str) -> String{ | |
l.iter().fold("".to_string(), | |
|a,b| if a.len()>0 {a+sep} else {a} + &b.to_string() | |
) | |
} |
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
struct Primes { | |
primes : Vec<u64>, | |
} | |
impl Primes { | |
fn new() -> Primes { | |
Primes{primes: vec![2]} | |
} | |
fn test(&self, totest: u64) -> bool { | |
let mut n = totest; |
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
struct Primes { | |
primes : Vec<u64>, | |
} | |
impl Primes { | |
fn new() -> Primes { | |
Primes{primes: vec![2]} | |
} | |
fn test(&self, totest: u64) -> bool { | |
let mut n = totest; |
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
<?php | |
function lambert2gps($x, $y, $lambert) { | |
$lamberts = array( | |
"LambertI" => 0, | |
"LambertII" => 1, | |
"LambertIII" => 2, | |
"LamberIV" => 3, | |
"LambertIIExtend" => 4, | |
"Lambert93" => 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 graham_scan(points) { | |
const pivot = points.reduce((c, p) => | |
p.y < c.y || p.y===c.y && p.x<c.x ? p : c); | |
const sorted = points | |
.map(p=>({x:p.x,y:p.y,angle:Math.atan2(p.y-pivot.y,p.x-pivot.x)})) | |
.sort((a,b) => a.angle === b.angle ? a.x - b.x : a.angle - b.angle); | |
function cross_p (a,b,c) {return (b.x-a.x)*(c.y-a.y) <= (b.y-a.y)*(c.x-a.x);} | |
var result = [sorted[0], sorted[1]], top = 1; | |
for(var i=2; i<sorted.length; i++){ | |
while (top >= 1 && cross_p(result[top-1], result[top], sorted[i])) top--; |
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
/** | |
* THIS CODE IS OUT OF DATE | |
* SEE: https://github.com/lovasoa/ZIF/ | |
**/ | |
class ZIF { | |
constructor(file) { | |
this.file = file; | |
this.head = this.parseHead(); // A promise for the header | |
} |
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 python3 | |
"""Use a csv file to fill a template""" | |
import sys | |
import csv | |
from string import Template | |
def csvfill(csvfile, template, outfilepattern): | |
t = Template(template) | |
fnametpl = Template(outfilepattern) | |
r = csv.DictReader(csvfile) |