Skip to content

Instantly share code, notes, and snippets.

let f a =
let t0 = Unix.gettimeofday() in
let acc = ref a in
for j = 1 to 10000000 do
acc := !acc +. (float_of_int j)
done;
let t1 = Unix.gettimeofday() in
Printf.printf "Time: %.3f %f\n%!" (t1-.t0) !acc
let _ =
module A {
export module B {
export var C:any = {}
}
}
module A {
export module B {
console.log("1", C);
function f(B) {
@zakki
zakki / gist:9245879
Created February 27, 2014 07:29
FizzBuzz
public class Foo {
public static void main(String[] args) {
try {
if (new javax.script.ScriptEngineManager().getEngineByExtension("js").eval(
"var i = 1\n" +
"while (i < 100) {\n" +
"if (i % 15 == 0) println('FizzBuzz')\n" +
"else if (i % 3 == 0) println('Fizz')\n" +
"else if (i % 5 == 0) println('Buzz')\n" +
"else println(i)\n" +
open Js
let f1 c =
c##prop1 <- true
(*
Val: val ff1 : < prop1 : < set : bool -> unit; .. > Js.gen_prop;
prop2 : < get : < prop1 : < set : bool -> unit; .. >
Js.gen_prop;
.. >
Js.t;
/*
$ cat foo.ml
let _ =
[1; 2; 3; 4]
|> List.map (fun a -> a * 2 + 1)
|> List.map string_of_int
|> List.iter print_endline
$ ocamlc foo.ml -output-obj -o foo.c
*/
(defun _ch_ (to_s_aM_ get_out_b_ outc_c_ outs_d_ flush_e_ k_f_ fmt_g_)
var out_C_=(caml_call_gen1_i_ get_out_b_,fmt_g_);
(defun outs_aj_ (s_a_)(return (caml_call_gen2_m_ outs_d_,out_C_,s_a_)))
(defun pr_aN_ (k_a_ n_b_ fmt_l_ v_aO_)
var len_j_=(fmt_l_.getLen );
(defun doprn_D_ (n_n_ i_b_)
var i_p_=i_b_;
for(;;)
(progn (if (<= len_j_ i_p_)
open Batteries
open Deriving_Show
module Show_batSet
(O : Set.OrderedType)
(K : Show with type a = O.t)
: Show with type a = Set.Make(O).t =
Defaults(
struct
module S = Set.Make(O)
@zakki
zakki / cast.ml
Last active December 26, 2015 20:28
class cs = object
method kuwa = prerr_endline "kuwa"
end
class ca = object
inherit cs
method x = 1
end
class cb = object
@zakki
zakki / applet.diff
Created October 17, 2013 06:43
Swing Explorer Applet Support
Index: src/org/swingexplorer/ActRefresh.java
===================================================================
RCS file: /cvs/swingexplorer/src/org/swingexplorer/ActRefresh.java,v
retrieving revision 1.4
diff -u -r1.4 ActRefresh.java
--- src/org/swingexplorer/ActRefresh.java 9 May 2009 14:19:04 -0000 1.4
+++ src/org/swingexplorer/ActRefresh.java 26 Jun 2009 01:14:54 -0000
@@ -21,36 +21,29 @@
package org.swingexplorer;
@zakki
zakki / gist:7019336
Created October 17, 2013 04:51
enum.scala:22: warning: match may not be exhaustive. It would fail on the following input: Some((x: Status.Status forSome x not in (Error, Processed, Rendering, Waiting)))
object Status extends Enumeration {
type Status = Value
val Waiting = Value("waiting")
val Rendering = Value("rendering")
val Processed = Value("processed")
val Error = Value("error")
}
object Main extends App {
import Status._