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
# coding: utf-8 | |
# irb(main):286:0> (scheme) | |
# ==> (+ 1 2) | |
# 3 | |
# ==> ((if (equal 1 1) * +) 2 3) | |
# 6 |
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
;; scheme interpreter | |
;; PAIP p714より引用 | |
;; CL-USER> (scheme) | |
;; ==> (set! fact (lambda (n) (if (= n 0) 1 (* n (fact (- n 1)))))) | |
;; #<COMPILED-LEXICAL-CLOSURE (:INTERNAL INTERP) #x2100A5E22F> | |
;; ==> (fact 5) | |
;; 120 | |
;; ==> ((if (= 1 1) * +) 3 4) | |
;; 12 |
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
# 2015-05-31 | |
# 制限時間3時間で迷路を解く問題 | |
# http://okajima.air-nifty.com/b/2010/01/post-abc6.html | |
class Path | |
attr_accessor :value, :prev, :f, :g, :h | |
def initialize(value: nil, g: 0, h: 0, prev: nil) | |
@value = value | |
@g = g | |
@h = h |
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時間56分58秒(-_-) | |
(defn problem1-a [lst] | |
(let [result (atom 0)] | |
(doall (for [x lst] (reset! result (+ @result x)))) | |
@result)) | |
(defun problem1-b [lst] | |
(let [result (atom 0) | |
i (atom 0) |
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
;; [2015-05-11] | |
;; C-M-.で進む、C-M-,で戻るが出来る便利関数 | |
;; 移動中はミニバッファに状況を表示します | |
;; 感想きかせてくれると嬉しいです | |
(require 'cl) | |
(defmacro kset (key fn) `(global-set-key (kbd ,key) ,fn)) | |
(defun substr (str start 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
(defun foldr (f lst) | |
(if (null (cdr lst)) (car lst) | |
(funcall f (car lst) (foldr f (cdr lst))))) | |
(defun foldl (f lst) | |
(if (null (cdr lst)) (car lst) | |
(funcall f (foldl f (butlast lst)) (car (last lst))))) | |
(defun foldr-tail (f a lst) | |
(if (null lst) a |
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
;; compose、compose2両関数とも同じ動きをするが、生成するラムダ式の構造が違う | |
;; (funcall (compose #'not #'evenp #'+) 3 2 2) | |
;; T | |
(defun compose (&rest fs) | |
(if (null (cdr fs)) | |
(car fs) | |
(let ((g (apply #'compose (cdr fs)))) | |
(lambda (&rest args) (funcall (car fs) (apply g args)))))) |
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 for (data &rest body) | |
(let* ((var (first data)) | |
(start (second data)) | |
(stop (third data)) | |
(gstop (gensym)) ) | |
`(do ((,var ,start (1+ ,var)) | |
(,gstop ,stop)) | |
((> ,var ,gstop)) | |
,@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
@echo off | |
setlocal enabledelayedexpansion | |
rem hh:mm:ssを3桁の英数字に変換する 2015-01-23 | |
rem 04:04:33 -> 45x | |
set hash=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX | |
for /l %%i in (0, 1, 9) do set hash[0%%i]=!hash:~%%i,1! | |
for /l %%i in (10, 1, 59) do set hash[%%i]=!hash:~%%i,1! |
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
;;;; 2014-12-17 | |
;;;; 麻雀あがり判定プログラム | |
;; (agari? "11122233344455m") | |
;; => | |
;; ("123m123m123m444m55m" | |
;; "111m234m234m234m55m" | |
;; "111m234m345m345m22m" | |
;; "111m222m333m444m55m") | |
;; 天和が出るまでひたすら配牌を繰り返す |