Skip to content

Instantly share code, notes, and snippets.

View michiakig's full-sized avatar

aki michiakig

  • Rent the Runway
  • Brooklyn, NY
View GitHub Profile
(*
CM.make "$/regexp-lib.cm";
*)
val getc: string -> (char, int) StringCvt.reader =
fn s => fn i =>
if (i < String.size s)
then SOME(String.sub(s, i), i+1)
else NONE
- val tree = Node("a",Node("b",Leaf,Leaf),Node("c",Leaf,Leaf));
val tree = Node ("a",Node ("b",Leaf,Leaf),Node ("c",Leaf,Leaf)) : string tree
- printTree tree;
a
/ \
b c
val it = () : unit
- val tree' = Node("x",Node("y",Leaf,Leaf),Node("z",Node("q",Leaf,Leaf),Node("w",Leaf,Leaf)));
- printTree t;
a
/ \
b c
/ \ / \
d e x y
/ \
q w
val it = () : unit
(require 'org-publish)
(setq org-publish-project-alist
'(("org-notes"
:base-directory "~/scratch/org/"
:base-extension "org"
:publishing-directory "~/scratch/public_html/"
:recursive t
:publishing-function org-publish-org-to-html
:headline-levels 4 ; Just the default for this project.
:auto-preamble t
(defun deep-rev (list)
(if (or (null list) (not (listp list))) list
(reverse (mapcar 'deep-rev list))))
(defun ext (cmd args)
(with-temp-buffer
(let ((exit (funcall 'call-process cmd nil (current-buffer) nil args)))
(cons exit (buffer-substring (point-min) (point-max))))))
#!/usr/bin/emacs --script
(princ (format "batch mode: %s\n" noninteractive))
utahraptor:~ aki$ rlwrap ocaml
Objective Caml version 3.12.1
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#lang eopl
;(module lang (lib "eopl.ss" "eopl")
(require "drscheme-init.scm")
(provide (all-defined))
;;;;;;;;;;;;;;;; grammatical specification ;;;;;;;;;;;;;;;;
(define the-lexical-spec
type 'a monoid = {zero : 'a; plus : 'a -> 'a -> 'a}
let sum (m : 'a monoid) (l : 'a list) : 'a = List.fold_left m.plus m.zero l
let string_summer = sum {zero = ""; plus = (^)}
let int_summer = sum {zero = 0; plus = (+)}