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
(define (twice x) (* 2 x)) | |
(define (sum x y) (+ x y)) | |
(use gauche.uvector) | |
(define-macro (ferr fmt . args) | |
; `(format (current-error-port) ,fmt ,@args)) | |
#t) | |
(define (read-exact u8buf len) |
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 perl | |
# | |
# unzip とか tar とかで、解凍するアーカイブファイルとしてURLを直接指定したい | |
# | |
# $HOME/bin とかに unzip ないし tar という名前で保存し chmod +x しておく。 | |
# $HOME/bin を環境変数PATHの冒頭に指定すること | |
# | |
use strict; | |
use File::Basename; |
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 <string.h> // memset, fls | |
#define MAX_TREE_HEIGHT 10 | |
#define TREE_BUFSIZE (1<<MAX_TREE_HEIGHT) | |
#define MAX_PAREN_DEPTH 16 | |
int bits(int x){ | |
return 1+fls(x); | |
// return 8*sizeof(int) - __builtin_clz(x); |
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
;; Gauche | |
(use srfi-1) | |
(use srfi-13) | |
(define (string-list< sl1 sl2) | |
(cond ((null? sl1) #t) | |
((null? sl2) #f) | |
((string< (car sl1) (car sl2)) #t) | |
((string> (car sl1) (car sl2)) #f) | |
(else (string-list< (cdr sl1) (cdr sl2))))) |
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 -*- | |
from pylab import * | |
from scipy.integrate import quad | |
x_min = -4.0 | |
x_max = 8.0 | |
xs = linspace(x_min, x_max, 256) | |
space = (x_max - x_min) / 80 | |
def fourier(fun, n_max): |
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
# | |
# k-means.awk | |
# | |
BEGIN { | |
if (K < 2) { | |
printf("usage: awk -f %s -v K=nnn datafile¥n", ARGV[0]) | |
exit | |
} | |
move_threshold = 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
;; a - b ÷ c = d! を満たす自然数の組 (a,b,c,d) ≦1億 を探す | |
(define MX 1e8) | |
(let ld ((d 3) (d- 2)) ; d- = (d-1)! | |
(when (<= (* d d-) MX) | |
(let lc ((c 2)) ;; c>1 | |
(when (< c d-) ;; b>0 | |
(receive (b r) (quotient&remainder | |
(* c d (- d- c)) | |
(- c 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
(use srfi-1) ;; cons* -> Gauche の組み込み list* でも可 | |
(define *ullman* #f) ;; Ullman先生方式なら#t | |
(define *verbose* #f) | |
;;; Finite Automata | |
(define (FA start finals states transitions) | |
(list 'FA start finals states transitions)) | |
(define (FA? f) (eq? 'FA (car f))) | |
(define (fa-start-state f) (second f)) |
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
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>surrogate pair test</title> | |
</head> | |
<body> | |
<p>"<span id="sample">𠀋</span>"</p><!-- U+2000B --> | |
<script type="text/javascript"> | |
var s = document.getElementById("sample").innerHTML; | |
document.write("<hr>"); |
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 python | |
# -*- coding: utf-8 -*- | |
''' | |
randpick: ファイルからn行をランダム抽出 | |
(c)2012 naoya_t | |
usage: randpick <input-file> <count> | |
''' | |
import sys |