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 exp = IfGt of int * int * block * block | |
| | Swap of int * int | |
| | Copy of int * int | |
| and block = exp list;; | |
| let rec eval a = function | |
| | IfGt(i, j, b1, b2) -> | |
| let (r,n) = evalBlock a (if a.(i) > a.(j) then b1 else b2) in | |
| (r, n+1) | |
| | Swap(i, j) -> |
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 std.stdio, std.algorithm; | |
| struct Exp { | |
| enum Tag { IfGt, Swap, Copy } | |
| Tag tag; | |
| int i, j; | |
| Exp[] bl1, bl2; | |
| } | |
| int eval(int[] a, const ref Exp 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
| type exp = IfGt of int * int * block * block | |
| | Swap of int * int | |
| | Copy of int * int | |
| and block = exp list;; | |
| let rec eval a = function | |
| | IfGt(i, j, b1, b2) -> | |
| 1 + evalBlock a (if a.(i) > a.(j) then b1 else b2) | |
| | Swap(i, j) -> | |
| let ai = a.(i) and aj = a.(j) in |
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 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 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 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 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
| #![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 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
| 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 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
| 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 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 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 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 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); | |
| } | |
| } |