2011-07-01から1ヶ月間の記事一覧

Haskell の sum と product を Scheme で実装

sum takes a list of numbers and returns their sum.product takes a list of numbers and returns their product. ghci> sum [5,2,1,6,3,2,5,7] 31 ghci> product [6,2,1,2] 24 ghci> product [1,2,5,6,7,9,2,0] 0 http://learnyouahaskell.com/starting-o…

空リストはアトムかリストか?

() もアトムの一種である。 とのことだが、Racketで > (list? '())とやると #t と評価される。空リストはアトムかリストか、結局どっちだ? ちなみにThe Little SchemerではS式がアトムかどうか判別する関数として (define (atom? x) (and (not (pair? x)) (…

SpringerLink eBooks ダウンローダー

SpringerLinkのebookは1章ずつしかダウンロードできないので面倒。全章ダウンロードして1つのPDFファイルに結合するまで自動で行うプログラムを作った。 #!/usr/bin/perl # slinkdown.pl use strict; use warnings; use Getopt::Long; use Web::Scraper; use…

アドレスの埋まる順番

C

今読んでいる教科書中の実行結果と、自分の環境下での実行結果が違ったのでメモ。 #include<stdio.h> //tes5.c int main() { int i; int num; int ary[5]; printf("The address of a is %p\n", &num); printf("The address of ary is %p\n", &ary); for(i=0;i<5;i++){</stdio.h>…

Twitter ダウンローダー

指定したTwitterアカウントのツイートを、指定した数だけテキスト形式でダウンロードするプログラム。 #!/usr/local/bin/perl # tdown.pl use strict; use warnings; use LWP::Simple; use Time::Piece(); # 本日の日付を名前にしたフォルダを作成 my $local…