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 can_sum<NumType: Num+PartialOrd, IterType: Iterator<NumType> + Clone> | |
(mut nums: IterType, total: NumType) -> bool { | |
let zero = std::num::Zero::zero(); | |
if total == zero {return true;} | |
if total < zero {return false;} | |
match nums.next() { | |
None => total == zero, | |
Some(x) => { | |
can_sum(nums.clone(), total-x) || can_sum(nums,total) | |
} |
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 math | |
def ent(l): | |
s = sum(l) | |
if s==0: return 0 | |
res = sum(-k/s * math.log2(k/s) for k in l if k != 0) | |
return res | |
def columns(m): | |
for i,_ in enumerate(m[0]): |
This file has been truncated, but you can view the full file.
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
PRAGMA foreign_keys=OFF; | |
BEGIN TRANSACTION; | |
CREATE TABLE lexique(ortho varchar, phon varchar, lemme varchar, cgram varchar, genre char, nombre char, freqlemfilms float, freqlemlivres float, freqfilms float, freqlivres float, infover varchar, nbhomogr integer, nbhomoph integer, islem boolean, nblettres integer, nbphons integer, cvcv varchar, p_cvcv varchar, voisorth integer, voisphon integer, puorth integer, puphon integer, syll varchar, nbsyll integer, cv_cv varchar, orthrenv varchar, phonrenv varchar, orthosyll varchar); | |
INSERT INTO "lexique" VALUES('a','a','a','NOM','m','',81.36,58.65,81.36,58.65,'',3,8,1,1,1,'V','V',25,18,1,1,'a',1,'V','a','a','a'); | |
INSERT INTO "lexique" VALUES('a','a','avoir','AUX','','',18559.22,12800.81,6350.91,2926.69,'ind:pre:3s','',3,8,0,1,'1','V','V',25,18,1,'1','a','1','V','a','a'); | |
INSERT INTO "lexique" VALUES('a','a','avoir','VER','','',13572.4,6426.49,5498.34,1669.39,'ind:pre:3s','',3,8,0,1,'1','V','V',25,18,1,'1','a','1','V','a','a'); | |
INSERT INTO "lexique" VALUES('a capella','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
var AutoCompletionInput = React.createClass({ | |
getInitialState: function() { | |
return {completion:'',prevText:''}; | |
}, | |
getCompletion : function(txt){ | |
if (txt.length === 0|| this.state.prevText.length>=txt.length) return ''; | |
var finder = function(x){return x.startsWith(txt)}.bind(this); | |
var repl = this.props.completionValues.find(finder); | |
if (!repl) return ''; | |
else return repl.substring(txt.length); |
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
comment "(*" "*)" ; | |
Prog. Program ::= [HeaderElem] [BodyElem] [FooterElem] ; | |
DefaultRate. HeaderElem ::= "directive" "default_rate" Number; | |
Stochasticity. HeaderElem ::= "directive" "stochasticity_absorption" Integer; | |
Sample. HeaderElem ::= "directive" "sample" Number; | |
separator HeaderElem ""; | |
InitState. FooterElem ::= "initial_state" [Process]; |
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
(* | |
New syntax, easier to read and to parse | |
Process definitions are optional (they can be inferred) | |
condition : bounce (params) | |
where | |
condition is a set of basic_conditions bound by "and" and "or" operators. | |
basic_condition can be of type (sortname comparisonOerator processNumber) or (sortname) which is a shortcut for (sortname>0) |
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
var lambda = .5; | |
var p = new Array(10); | |
for(var i=0; i<p.length;i++) p[i]=0; | |
p[2]=1; | |
var niter = 3; | |
for (var k=0;k<niter;k++){ |
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
var MAX = 3; | |
var a=0, b=0, n=0, p=0; | |
var ncorr = 0, pred=0; | |
var histpred = {}; | |
var hist = [false,false,false,false]; | |
for (var i=0; i<24; i++) { | |
a = (a+1)%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 <unistd.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/wait.h> | |
#define MAXS (255) | |
int main(void) { |
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 <stdlib.h> | |
#include <unistd.h> | |
#include <signal.h> | |
#include <pthread.h> | |
#define NPROC (10) | |
int procnums[NPROC]; | |
enum mode_t {VULNERABLE, PROT1, PROT2}; |