Wednesday, April 30, 2008

Syntax

This link has a bunch of different pages on syntax for different languages, going all of the way back to BCPL and Fortran. Unfortunately, some of the pages are nearly empty, and not due to the lack of syntax.

fibo.hs

My first Haskell program! The recursive functions and induction from CSE321 inspired me to write a simple Fibonacci sequence generator:

fibo.hs

import System.Environment

-- The almighty Fibonacci generator!
fibo :: Integer -> Integer
fibo 0 = 1
fibo 1 = 1
fibo n | n > 1 = fibo(n - 2) + fibo(n - 1)


-- Generates a list of the appropriate numbers
fibosequence :: Integer -> [Integer]
fibosequence 0 = [1]
fibosequence n | n > 0 = fibosequence(n - 1) ++ [fibo(n)]


str2int :: String -> Integer
str2int = read


-- For generating a single number per argument
fibolist :: [String] -> String
fibolist [] = ""
fibolist (x:xs) = x ++ ": " ++ show(fibo(str2int(x))) ++ "\n" ++ fibolist(xs)


-- For generating a list per argument
fiboslist :: [String] -> String
fiboslist [] = ""
fiboslist (x:xs) = x ++ ": " ++ show(fibosequence(str2int(x))) ++ "\n" ++ fiboslist(xs)




main = do x <- getArgs
putStr(fiboslist(x))
% ./fibo 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0: [1]
1: [1,1]
2: [1,1,2]
3: [1,1,2,3]
4: [1,1,2,3,5]
5: [1,1,2,3,5,8]
6: [1,1,2,3,5,8,13]
7: [1,1,2,3,5,8,13,21]
8: [1,1,2,3,5,8,13,21,34]
9: [1,1,2,3,5,8,13,21,34,55]
10: [1,1,2,3,5,8,13,21,34,55,89]
11: [1,1,2,3,5,8,13,21,34,55,89,144]
12: [1,1,2,3,5,8,13,21,34,55,89,144,233]
13: [1,1,2,3,5,8,13,21,34,55,89,144,233,377]
14: [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610]
15: [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]

Tuesday, April 29, 2008

二隻の舟 - 中島みゆき

二隻の舟 (Nisou no fune, "Two Ships") came to me in an interesting way: on two different albums with slightly different mixes for this song. The later one is much more piano-intensive, yet the earlier one is a lot more mellow. I thought they were the same, until I listened to them more carefully today. Even more interesting is that the first song continues into another (糸: ito, "Thread") that I already knew.

時は 全てを連れてゆくものらしい
なのに どうして 寂しさを置き忘れてゆくの
いくつになれば 人懐かしさを
うまく捨てられるようになるの

難しいこと望んじゃいない
有り得ないこと望んじゃいない

時よ 最後に残してくれるなら
寂しさの分だけ 愚かさをください

おまえとわたしは たとえば二隻の舟
暗い海を渡ってゆく ひとつひとつの舟
互いの姿は波に隔てられても
同じ歌を歌いながらゆく 二隻の舟

時流を泳ぐ海鳥たちは
むごい摂理をささやくばかり
いつかちぎれる絆 見たさに
高く高く高く

敢えなくわたしが 波に砕ける日には
どこかでおまえの舟が かすかにきしむだろう
それだけのことで わたしは海をゆけるよ
たとえ舫い網は切れて 嵐に飲まれても
きこえてくるよ どんな時も

おまえの悲鳴が 胸にきこえてくるよ
越えてゆけ と叫ぶ声が ゆくてを照らすよ

おまえの悲鳴が 胸にきこえてくるよ
越えてゆけ と叫ぶ声が ゆくてを照らす

難しいこと望んじゃいない
有り得ないこと望んじゃいないのに

風は強く波は高く 闇は深く 星も見えない
風は強く波は高く 暗い海は果てるともなく
風の中で波の中で たかが愛は 木の葉のように

わたしたちは二隻の舟 ひとつずつの そしてひとつの
わたしたちは二隻の舟 ひとつずつの そしてひとつの
わたしたちは二隻の舟

Monday, April 28, 2008

jdic.bz2

I've decided to be nice, and am providing a database dump for the PostgreSQL search scripts for the EDICT. Here it is: jdic.bz2

What's interesting is that it's only a little bit larger than the edict.gz file from which it is generated.

Sunday, April 27, 2008

nlaunch3.1

Here's another release of nlaunch: nlaunch3.1-20080427.tar.bz2

I'm wondering if I should create a page specifically for this purpose, but then I realize nobody would even bother to look. At least someone looks at this blog every now and then.

Saturday, April 26, 2008

Linuxfest Northwest!

Icy Tux

I just got back from LinuxFest Northwest today, and boy was it a blast. I took the Pogo Express (this year an articulated Gray Lines bus) to BTC, and even the bus ride was a lot of fun. I've never found myself so social. I attended talks on networking protocols, natural language processing, and Jabber. For the last session, I even got to explore the OLPC XO-1 with friends, using its mesh networking features.

Icy Tux

While there, I also picked up large amounts of mainly free things, but a few things that cost money. For $30, I also bought this at a used parts section of the meet, and it looks like it turns on, but I can't do much with this until I get the proper adapters.

I can say I had fun, and I can't wait until next year.

Dominic Deegan and lolcats

It looks like Dominic Deegan: Oracle for Hire, one of the first webcomics I've ever read (and am still reading), has gotten into the lolcat spirit. The third panel here shows it all. That one gave me a big laugh, too.