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
type exp = IfGt of int * int * block * block | |
| Swap of int * int | |
| Copy of int * int | |
and block = exp list;; | |
let evalBlock a blk = | |
let rec eval = function | |
| IfGt(i, j, b1, b2) -> go 1 (if a.(i) > a.(j) then b1 else b2) | |
| Swap(i, j) -> | |
let ai = a.(i) and aj = a.(j) in |
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
type exp = IfGt of int * int * block * block | |
| Swap of int * int | |
| Copy of int * int | |
and block = exp list;; | |
let rec eval (a : int array) = function | |
| IfGt(i, j, b1, b2) -> go a 1 (if a.(i) > a.(j) then b1 else b2) | |
| Swap(i, j) -> | |
let ai = a.(i) and aj = a.(j) in | |
a.(i) <- aj; a.(j) <- ai; 1 |
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
#![allow(unstable)] | |
enum Exp { | |
IfGt(usize, usize, Vec<Exp>, Vec<Exp>), | |
Swap(usize, usize), | |
Copy(usize, usize) | |
} | |
fn eval(a : &mut Vec<i32>, e : &Exp) -> i32 { | |
match *e { |
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
If [0] > [1] | |
Swap [0] [1] | |
If [2] > [3] | |
Swap [2] [3] | |
If [4] > [5] | |
Swap [4] [5] | |
If [6] > [7] | |
Swap [6] [7] | |
If [0] > [2] | |
Swap [0] [2] |
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
If [0] > [1] | |
Swap [0] [1] | |
If [2] > [3] | |
Swap [2] [3] | |
If [4] > [5] | |
Swap [4] [5] | |
If [6] > [7] | |
Swap [6] [7] | |
If [0] > [2] | |
Swap [0] [2] |
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
(function doReplace() { | |
$("span").each(function(ind, span) { | |
var re = /\d+\.\d+\.\d+\.\d+/i; | |
var org = span.innerHTML; | |
var found = span.textContent.match(re); | |
if (found) { | |
span.textContent = span.textContent + " address search in progress ... "; |
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 std.stdio, std.digest.md, std.range, std.algorithm, std.ascii, std.conv, | |
std.concurrency, std.parallelism : totalCPUs; | |
char nextByte(char x) { | |
switch(x) { // this could be a one-liner: return x == '9' ? 'a' : ... | |
case '9' : return 'a'; | |
case 'z' : return '0'; | |
default : return cast(char)(x+1); | |
} | |
} |
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
newtype Qeust b a = Qeust ((a -> b) -> a) | |
instance Functor (Qeust b) where | |
fmap f (Qeust aba) = Qeust (\ cb -> f (aba (\a -> cb (f a) ) )) | |
-- aba :: ((a -> b) -> a) | |
-- f :: a -> c | |
-- res :: Qeust b c | |
-- cb :: c -> b | |
-- f a :: c |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func player(from chan int, to chan int, end chan int) { | |
for { | |
v := <-from |
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 std.stdio, core.thread, std.concurrency, std.datetime, core.atomic; | |
class Chan(T) { | |
T store; | |
bool haveData = false; | |
this() {} | |
void send(T v) shared { | |
while(haveData) yield(); |