Skip to content

Instantly share code, notes, and snippets.

sealed trait NameOpt extends Any {
def isEmpty: Boolean
def get: (String, String)
}
object NameOpt {
object Empty extends NameOpt {
def isEmpty: Boolean =
true
class A {
val v = (x: Int) => x * 3
def f(x: Int) = x * 3
}
object A {
def v() {
val a = new A
var i = 0
var n = 1
while (i < 1000000) {
@zakki
zakki / gist:5531852
Last active December 17, 2015 01:58
module and localvariable
module a{
export module b{
export var hoge;
export function f() {
hoge = 0;
var b = 0;
return b;
}
}
}
(defun fix-ocaml-cursor-position (byte-pos)
(let ((len (lambda (p)
(length (encode-coding-string
(buffer-substring 1 p) buffer-file-coding-system)))))
(let* ((pos (/ byte-pos 4))
(b (funcall len pos)))
(while (< b (- byte-pos 1))
(setq pos (+ pos 1))
(setq b (funcall len pos)))
pos)))
@zakki
zakki / AO.h
Created November 9, 2012 09:30
j2objc aobench
//
// Generated by the J2ObjC translator. DO NOT EDIT!
// source: AO.java
//
// Created by mac on 12/11/09.
//
@class IOSIntArray;
@class IOSObjectArray;
@class Intersection;
///<reference path='..\typescript\src\harness\harness.ts'/>
///<reference path='..\typescript\src\harness\baselining.ts'/>
///<reference path='..\typescript\src\harness\external\json2.ts'/>
///<reference path='..\typescript\src\compiler\optionsParser.ts'/>
class Dumper {
constructor (public ioHost: IIO) {
}
open Batteries_uni
let (>>=) = Lwt.bind
let http_get url =
Printf.printf "sleep\n";
Lwt_unix.sleep 2.0 >>= (fun () ->
Printf.printf "wake up\n";
Lwt.return ("data '" ^ url ^ ""));;
let _ =
<?php
for ($i = 1; $i <= 100; $i++) {
if ($i % 3 == 0) {
?>
print_string "Fizz";
<?php
}
if ($i % 5 == 0) {
?>
@zakki
zakki / debug_info.diff
Created September 5, 2012 10:06
js_of_ocaml debug info
diff -rN -u old-js_of_ocaml/compiler/driver.ml new-js_of_ocaml/compiler/driver.ml
--- old-js_of_ocaml/compiler/driver.ml 2012-09-05 19:02:07.000000000 +0900
+++ new-js_of_ocaml/compiler/driver.ml 2012-09-05 19:02:07.000000000 +0900
@@ -20,7 +20,7 @@
let debug = Util.debug "main"
-let f ?standalone p =
+let f ?standalone (p, d) =
if debug () then Code.print_program (fun _ _ -> "") p;
let window = Dom_html.window;;
let foo i =
let result = try Some (List.find (fun s -> s = i) [0; 1; 5]) with Not_found -> None in
match result with
Some(n) -> window##alert(Js.string (Printf.sprintf "foo Some(%d)" n))
| None -> window##alert(Js.string "foo None");;
for i = 0 to 3 do
foo i