.scm

'0' in 0~1000

0〜1000に含まれる0をカウントする - os0x.blog for(var i=0,c='';i<1001;++i)c+=i+'';alert(c.match(/0/g).length); ふむ。とりあえず for(i=c='';i<1001;)c+=i++;alert(c.match(/0/g).length) 枝葉を落として 53B。IE/Safari を捨てるなら // ↓ match/leng…

golche

object-applyでgorubyっぽいことをする試み。 (extend srfi-1 util.combinations) (define (matching-symbols key) (define (pack-capture-sizes mat) (fold (lambda (i r) (+ (string-size (mat i)) (* r 32))) 0 (iota (- (rxmatch-num-matches mat) 1) 1)…

regexp-replace-allと\b

http://ja.doukaku.org/comment/6960/ 例のmawkのgsubと同じ挙動なのか。使い辛いな。

slope lines

リストの指定位置を更新する書き方が分からずVectorを使ったらダントツでビリ。 $ gosh -E 'let1 v #(0 1 2) (set! (ref v 2) 3) (print v) (exit)' #(0 1 3) $ gosh -E 'let1 l `(0 1 2) (set! (ref l 2) 3) (print l) (exit)' gosh: "error": no applicabl…

golf-buffer-scheme

ゴルフしたコードが余りに読み辛いのでscheme-modeを導入した上で作成。 (defun golf-buffer-scheme () (interactive) (let ((spc "[ \r\n\t]") (-- "\\|")) (replace-buffer (compile-regexp (concatenate 'string spc "*" "\\(" ; <1> "\"\\(?:[^\"]\\|\\\…

text.trと#\\

koderaさんのをGaucheで真似ようとして失敗。 gosh> (use text.tr) #<undef> gosh> (string-tr "\\('-')/" "\\\\/'" "_ \\\\") "\\( - )_"どうも妙なのでソースを覗いてみると… ;; Gauche-0.8.13/libsrc/text/tr.scm 108-117 (define (start c r) (cond ((eof-objec</undef>…

(gauche :golf 0)

簡単な問題なら縮むようになってきた。 rec / cut / pa$ 生lambdaの出番は無さそう。 `(x,y,@z) = (quasiquote (x (unquote y) (unquote-splicing z))) 「 (cons x y) 」より「 `(,x,@y) 」。 「 (rec(_ x) ...) 」より「 (rec'x ...) 」*1。 #/appliable re…