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
let memoize f = | |
let table = Hashtbl.create 10 in | |
fun p -> try Hashtbl.find table p | |
with Not_found -> | |
let _ = print_string "not found (memoize)\n" in | |
let v = f p in | |
let _ = Hashtbl.add table p v in | |
v | |
let memoize2 f = |
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
(defun expand-params (params body &optional wrapper) | |
(if (= 1 (length params)) | |
(if wrapper | |
`(,wrapper (lambda (,(car params)) ,@body)) | |
`(lambda (,(car params)) ,@body)) | |
(if wrapper | |
`(,wrapper (lambda (,(car params)) ,(expand-params (cdr params) body wrapper))) | |
`(lambda (,(car params)) ,(expand-params (cdr params) body wrapper))))) | |
(defmacro defcurry (name (&rest params) &body body) |
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
getLexerIndentLevel :: Alex Int | |
getLexerIndentLevel = Alex $ \s@AlexState{alex_ust=ust} -> Right (s, indentation ust) | |
setLexerIndentLevel :: Int -> Alex () | |
setLexerIndentLevel i = Alex $ \s@AlexState{alex_ust=ust} -> Right (s{alex_ust=(AlexUserState i)}, ()) | |
collectIndent :: AlexInput -> Int -> Alex Lexeme | |
collectIndent input@(p, _, _, str) i = do | |
lastIndent <- getLexerIndentLevel | |
currIndent <- countIndent (drop 1 str) 0 |
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
(defmacro defcont (name (&rest params) &body body) | |
(let ((result (gensym))) | |
`(defun ,name (continuation ,@params) | |
(let ((,result ,@body)) | |
(funcall continuation ,result))))) | |
(defun call/cc (continuation fun) | |
(funcall fun continuation)) | |
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
{ | |
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
"font_face": "Droid Sans Mono", | |
"font_size": 8, | |
// "gutter": false, | |
"highlight_line": true, | |
"caret_style": "solid", | |
"trim_trailing_white_space_on_save": true, | |
"save_on_focus_lost": true, | |
"highlight_modified_tabs": true, |
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
λ> (make-application (read "+") (read "'(1 2)")) | |
<Syntax> | |
λ> (eval (make-application (read "+") (read "'(1 2)"))) | |
3 | |
λ> eval | |
<Fexpr> | |
λ> (defun garip-fn (fn param) (+ 10 (fn param))) | |
<Function> |
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
λ> (defun id (x) x) | |
applyCont DefineCont "id" EndCont env >>apply, eval, first, rest, cons, eq, +, -, *, div, mod, quot, rem, =, <, >, /=, >=, <=, &&, ||, string?, symbol?, number?, list?, boolean?, symbol->string, type-of, println, read, make-application, nil<< val <Function> | |
applyCont EndCont env >>id, apply, eval, first, rest, cons, eq, +, -, *, div, mod, quot, rem, =, <, >, /=, >=, <=, &&, ||, string?, symbol?, number?, list?, boolean?, symbol->string, type-of, println, read, make-application, nil<< val <Function> | |
<Function> | |
λ> (defun map (fun lst) (if (eq (list) lst) lst (cons (fun (first lst)) (map fun (rest lst))))) | |
applyCont DefineCont "map" EndCont env >>id, apply, eval, first, rest, cons, eq, +, -, *, div, mod, quot, rem, =, <, >, /=, >=, <=, &&, ||, string?, symbol?, number?, list?, boolean?, symbol->string, type-of, println, read, make-application, nil<< val <Function> | |
applyCont EndCont env >>map, id, apply, eval, first, rest, cons, eq, +, -, *, div, mod, quot, rem, =, <, >, /=, >=, <=, &&, ||, st |
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
from django.core.management.base import BaseCommand | |
from main.models import * | |
class Command(BaseCommand): | |
def handle(self, *args, **options): | |
for post in Post.objects.all(): | |
name = post.date.strftime("%Y-%m-%d") + "-" + post.verbose_name + ".markdown" | |
full_date = post.date.strftime("%Y-%m-%d %H:%M") |
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
{-# OPTIONS_GHC -Wall | |
-fno-warn-missing-signatures | |
-fno-warn-hi-shadowing | |
-fno-warn-unused-do-bind | |
-fno-warn-name-shadowing #-} | |
module Poly where | |
--import Control.Monad.Identity | |
import Control.Monad.Error |
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
➜ ~ ocaml | |
OCaml version 4.00.0 | |
# type record1 = { x : int; y : int };; | |
type record1 = { x : int; y : int; } | |
# { x = 10; y = 20 };; | |
- : record1 = {x = 10; y = 20} | |
# type record2 = { x : int };; | |
type record2 = { x : int; } | |
# { x = 10; y = 20 };; |