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
| (require 'cl-test-more) | |
| (defpackage infix | |
| (:use :cl :cl-test-more)) | |
| (in-package :infix) | |
| (defun simple-binary (sym) | |
| #'(lambda (left right) | |
| (list sym left right))) |
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
| augroup scmprog | |
| au! | |
| autocmd BufNewFile,BufRead *.scm,*.sch let b:is_chicken=1 | |
| autocmd BufNewFile,BufRead *.scm,*.sch set ft=scheme sts=2 sw=2 autoindent lisp showmatch | |
| augroup END | |
| augroup lisp | |
| autocmd FileType lisp set sts=2 sw=2 | |
| augroup END |
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
| (defn decimal-divide-by-9 [n] | |
| (letfn [(digit-value [digit] | |
| (- (.charCodeAt digit 0) | |
| (.charCodeAt "0" 0))) | |
| (place-values-+ [place-values addend] | |
| (cond | |
| (= 0 addend) place-values | |
| (seq place-values) (conj (rest place-values) | |
| (+ addend (first place-values))) |
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
| (ns splay-rope.core) | |
| (declare traverse) | |
| (deftype Node [^int offset | |
| ^String data | |
| left | |
| right] | |
| Object | |
| (toString [node] |
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
| ;; 1. What I'm testing: A rope implementation where the binary tree is | |
| ;; balanced by splaying. | |
| ;; 2. To simplify things, it supports one update operation: | |
| ;; (splice rope start-offset end-offset new-data) | |
| ;; 3. I'd like to verify that the nodes are in the right order and other | |
| ;; properties after multiple splicings | |
| ;; Here's a spec I wrote for testing that the rope has the right | |
| ;; string representation after a single insertion-type splice: |
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
| (defmacro defhandler | |
| [& args] | |
| (let [tags (take-while keyword? args) | |
| [keystroke handler-args & handler-body] (drop-while keyword? args)] | |
| `(def ^{:handles ~keystroke} handler# | |
| (make-handler ~@tags (fn ~handler-args ~@handler-body))))) |
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
| (ns avi.compose) | |
| (declare ^:private splice-form) | |
| (defn- splice-normal-form | |
| [value form] | |
| (apply list (first form) value (rest form))) | |
| (defn- splice-if-form | |
| [value form] |
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
| #!/usr/bin/env ruby | |
| def levenshtein_edit_distance(a,b) | |
| dp = Array.new(a.length + 1) {Array.new(b.length + 1, 99999999)} | |
| dp[0][0] = 0 | |
| 1.upto(a.length) {|i| dp[i][0] = i} | |
| 1.upto(b.length) {|j| dp[0][j] = j} | |
| 1.upto(a.length) do |i| | |
| 1.upto(b.length) do |j| | |
| dp[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
| #!/bin/sh | |
| ( | |
| printf 'unset SSH_CLIENT\n' | |
| printf 'unset SSH_AUTH_SOCK\n' | |
| printf 'unset SSH_CONNNECTION\n' | |
| printf 'unset SSH_TTY\n' | |
| set |grep ^SSH |sed 's/^/export /' | |
| ) > ~/.ssh/vars |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| char op; | |
| int a, b; | |
| scanf("%c %d %d", &op, &a, &b); | |
| switch (op) { | |
| case '+': printf("%d\n", a + b); break; |