Haskellで、フィボナッチ数列を求めるロジックを書いてみた。


このあたりでも似たような試みがされている。

Fibonacci numbers (Haskell)

n+k パターンは、HaskellReport2010 で削除されているうえ、処理速度に問題がある。

で、こんな感じ。


fin :: Int -> [Integer]

fin = \n -> take n $ reverse $ fincalc [] n
where
fincalc xs 0 = xs
fincalc [] n = fincalc [1,0] n
fincalc (x:y:xs) n = fincalc ((x+y):x:y:xs) (n-1)


数百列程度なら瞬時に計算結果を返してくれる。
ソースコードからのビルド中に下記のエラー発生。

In file included from GHOST_SystemX11.cpp:34:
GHOST_WindowX11.h:40:35: error: X11/extensions/XInput.h: No such file or directory

ここで、以下のように打つ。

#sudo apt-get install libxtst-dev

で確認。

find /usr/include/ -name XInput.h
/usr/include/X11/extensions/XInput.h

目的のヘッダーファイルが取得されたのが確認できた。

今回の情報源はコチラ。

https://bugs.launchpad.net/ubuntu/+source/libxtst/+bug/273386

1.Life is not fair. Get used to it

2.The world won't care about your self-esteem. The world will expect you to accomplish something BEFORE you feel good about yourself.

3.You will NOT make 40 thousand dollars a year right out of high school. You won't be a vice president with car phone, until you earn both

4.If you think your teacher is tough, wait till you get a boss. He doesn't have tenure

5.Flipping burgers is not beneath your dignity. Your grandparents had a different word for burger flipping they called it Opportunity

6.If you mess up,it's not your parents' fault, so don't whine about your mistakes, learn from them.

7.Before you were born, your parents weren't as boring as they are now. They got that way from paying your bills, cleaning your clothes and listening to you talk about how cool you are. So before you save the rain forest from the parasites of your parent's generation, try delousing the closet in your own room.

8.Your school may have done away with winners and losers, but life has not. In some schools they have abolished failing grades and they'll give you as many times as you want to get the right answer. This doesn't bear the slightest resemblance to ANYTHING in real life.

9.Life is not divided into semesters. You don't get summers off and very few employers are interested in helping you find yourself. Do that on your own time.

10.Be nice to nerds. Chances are you'll end up working for one.

An OS for Personal Computing

より

HAIKU
の紹介記事ですね。

記事自体には、誤りが多くトラッカーに指摘されていますが、
最近忘れていた、
HAIKU
の存在を思い出させてくれた
ことには感謝。


BeOS
クローンということもあり、
懐かしく感じる方も多いのではないでしょうか。


去る5/10に、Alpha2がリリースされていたようです。


公式サイトより

Haiku Project Announces Availability of Haiku R1/Alpha 2

Linux との比較で
相変わらず、
モノリシックだ
モジューラだの
いわれているようですね。

個人的には、

Database-like file system (OpenBFS) with support for indexed metadata

に興味があります。


インストールについては

CDイメージや、
VMWare
のブートイメージなどもあるようです。

USBブートにも対応している模様。


早速、ダウンロードして動かしてみよう。

BeOSバイブル〈Volume1〉/スコット ハッカー

¥4,725
Amazon.co.jp

BeOS:ファイルシステム―実践ファイルシステム構築/ドミニク ジャンパオロ

¥3,990
Amazon.co.jp

Twitter もどきを JRuby on Rails で書いてみる Part7

の続き。

まず、
view
の編集から。

投稿内容が表示されているリストの上に、
入力用フォームを置いてみる。

app/views/home/index.html.erb

に以下を追記。

---------------------------
<table>

<% form_for :post, Post.new ,:url =>{:action => "add"} do |f| %>

<%= f.error_messages %>

<p>
<%= f.label :name %>

<%= f.text_field :name %>
</p>
<p>
<%= f.label :title %>

<%= f.text_field :title %>
</p>
<p>
<%= f.label :content %>

<%= f.text_field :content %>
</p>
<p>
<%= submit_tag "Create" %>
</p>
<% end %>
</table>
---------------------------

post
クラスの属性に入力フィールド
を対応させ配置している。

Create
ボタン押下時に
コントローラの
add
メソッドが呼び出されるように
指定する。


続いて、
controller

add
メソッドを追加してやる。

app/controllers/home_controller.rb

---------------------------

def add
@newpost = Post.new(params[:post])
@newpost.save

@posts = Post.find(:all,:order=>"id desc",:limit=>10)

respond_to do |format|
format.html { render :action => "index"}
format.xml { render :xml=> @posts }
end

end

---------------------------

リクエストパラメータ
から
postクラスに属性をセットして
save
メソッドで登録。

遷移先を
index
に指定して
元のページに戻る。

投稿内容を再度取得して
リストにセット。
この情報は、
画面描画の際に再表示される。


とりあえず、
投稿と閲覧ができるようになった。

次回はユーザー制御に取りかかる予定。

Railsレシピブック 183の技/高橋 征義

¥2,940
Amazon.co.jp

JRuby on Railsシステム構築入門 (DB Magazine SELECTION)/橋本 吉治

¥2,814
Amazon.co.jp

実践 Rails ―強力なWebアプリケーションをすばやく構築するテクニック/Brad Ediger

¥3,150
Amazon.co.jp

emacs-rails setup 2


セットアップは
完了しているので
実際の使い方について。


emacs-rails

ディレクトリに入っている

README

ファイルに記述がある。


------------------------------------------

== Features

* TextMate-like snippets
* Display of colored log files
* Integration with script/generate and script/destroy (controller,
model, scaffold, migration, etc)
* Integration with script/console and script/breakpointer
* Run rake %(key)C-c C-c r%
* Quick start svn-status in RAILS_ROOT %(key)f9%
* Documentation search using *ri* or *chm* file and Rails API
reference in HTML %(key)f1%
* Quick access to the main configuration files
* Automatic TAGS generation in RAILS_ROOT directory

=== Management of WEBrick/Mongrel

* Your can select Webrick, Mongrel or Lighttpd
* Start/stop application server %(key)C-c C-c w s%
* Automatic browsing on current action (from view or controller)
%(key)C-c C-c w a%

=== Navigation in RAILS_ROOT hierarchy

* Quick switch stylesheets, javascripts, migrations, layouts, helpers,
controllers, models, observers, plugins
* In controller file: go to views, functional test, helper
%(key)C-down%
* Switch between action/view %(key)ム-up%
* Go to file in current line (example: cursor at line [redirect_to
controller => :home, :action => "show"], will be open action "show"
in "home" controller) %(key)C-RET%
* Quick access to the main configuration files using menu

Other hot keys

* %(key)C-c C-c g g% rails-nav:goto-migrate
* %(key)C-c C-c g j% rails-nav:goto-javascripts
* %(key)C-c C-c g s% rails-nav:goto-stylesheets
* %(key)C-c C-c g l% rails-nav:goto-layouts
* %(key)C-c C-c g h% rails-nav:goto-helpers
* %(key)C-c C-c g c% rails-nav:goto-controllers
* %(key)C-c C-c g m% rails-nav:goto-models
* %(key)C-c C-c g o% rails-nav:goto-observers
* %(key)C-c C-c g p% rails-nav:goto-plugins

=== ERb refactoring

* Create partial from selection %(key)C-c p%
* Create helper from block %(key)C-c b%

------------------------------------------

個人的に役立っているのは。


*snippet によるコード補完。

*script/generate and script/destroy
(controller, model, scaffold, migration) の統合。

*script/console and script/breakpointer の統合。

* Ctrl+C / Ctrl+C / r で rake 起動。

* F1 キーで リファレンスの参照。

* Controller ファイル内で Ctrl+c / ↓ で、 view/helper/functional test へジャンプ。

* Ctrl+c / ↑ で、 view/action の切り替え。

* view の編集時に Ctrl+c / Ctrl+x / w / a でブラウジング。

などなど。


便利なツール Emacsらくらく入門/藤原 誠

¥2,499
Amazon.co.jp

GNU Emacsデスクトップリファレンス (UNIX text processing)/デブラ キャメロン

¥683
Amazon.co.jp

入門 GNU Emacs 第3版/Debra Cameron

¥3,990
Amazon.co.jp

OGNL


ソースコード

取得しようと公式ページを
探してみたが見当たらない。

ここ

参照すると。

-------------------------------------------------------------
Anonymous Access

java.net does not provide CVS access without first signing up for a java.net user account. Once you have done this, you can get the source by doing the following:
cvs -d :pserver:[username]@cvs.dev.java.net:/cvs login
cvs -d :pserver:[username]@cvs.dev.java.net:/cvs checkout ognl

-------------------------------------------------------------

とある。

どうやら
java.net
内に開発拠点を移動したようだ。

指示されたとおりに、
cvs
コマンドを実行して
ソースコード一式を取得。

#cd ognl
#ant

で、
build
ディレクトリ
が生成され

ognl-2.6.9.jar

が出来上がった。


以下のコードで
動作を確認してみる。

hoge
オブジェクトを生成し、
OGNL式に基づいて
値の取得と更新を行う。


------------------------------------


import ognl.Ognl;
import ognl.OgnlContext;
import java.util.Map;
import java.util.HashMap;

public class Sample{

public static void main(String args[]){

try{
OgnlContext context = new OgnlContext();
context.put("hoge",new Hoge());

String expression = "hoge.mode";
Object parseExpression = Ognl.parseExpression(expression);
Integer mode = (Integer) Ognl.getValue(parseExpression, context);
System.out.println(mode);


Ognl.setValue(parseExpression, context, new Integer(10));


parseExpression = Ognl.parseExpression(expression);
mode = (Integer) Ognl.getValue(parseExpression, context);
System.out.println(mode);


}catch(Exception e){
e.printStackTrace();
}

}
}
class Hoge{
private int mode = 0;

public int getMode(){return mode;}

public void setMode(int m){ mode = m;}

}



------------------------------------

出力結果

------------------------------------
0
10
------------------------------------


増補改訂版Java言語で学ぶデザインパターン入門/結城 浩

¥3,990
Amazon.co.jp

独習Java 第4版/ジョゼフ・オニール

¥3,360
Amazon.co.jp

明解Java 入門編/柴田 望洋

¥2,730
Amazon.co.jp

はやぶさ公式ページ

より


いよいよ
最後のミッションです。


-----------------------------------------

2010年6月12日

「はやぶさ」のカプセル再突入計画実施決定

「はやぶさ」の軌道評価を行った結果、正常に推移していることを確認いたしましたので、お知らせいたします。
 これより、大気圏再突入に向けた計画を実施します。

探査機の状態は良好です。

大気圏再突入に向けた主な計画は以下の通りです。
・6月13日 19時51分(JST)頃:カプセル分離
・6月13日 22時51分(JST)頃:カプセル再突入

-----------------------------------------


ネット中継もあるようです。


JAXA 宇宙科学研究所
はやぶさ管制室からライブ中継 
6月13日(日)18:00~24:00




第35回】はやぶさカプセル帰還ライブ放送 
2010年6月13日(日) 12:45~15:00 19:30~24:00


WSJ

JAPAN REAL TIME

でも触れています。


-----------------------------------------
Sunday: Japan’s asteroid probe Hayabusa returns after spending seven years in space, and is expected to come back to Earth with presents: world’s first samples of an asteroid’s surface.
-----------------------------------------

7年に渡る調査を称えるとともに、
人類初となる
小惑星の表面サンプル
の帰還を
期待している。


ライブ中継から目が離せません。

こんな夜は

このアルバムで

遥かなる宇宙に夢を馳せる。



The Dark Side of the Moon/Pink Floyd

¥1,828
Amazon.co.jp

対/Pink Floyd

¥2,345
Amazon.co.jp

emacs-rails setup

の続き。

RubyForge emacs-rails

より、

emacs-rails-0.5.99.5.tar.gz

をダウンロード。

#tar -zxf emacs-rails-0.5.99.5.tar.gz

#mv emacs-rails ~/.emacs.d/rails


#less ~/.emacs.d/rails/README

とりあえず

README

を読む。

------------------------------------

== Instalation

You need download last release from RubyForge page
"http://rubyforge.org/projects/emacs-rails" and and unpack
it to directory containing libraries of Emacs, by default it's
$HOME/.emacs.d/

You can also use SVN

cd $HOME/.emacs.d/
svn co svn://rubyforge/var/svn/emacs-rails/trunk emacs-rails

Download and install required libraries

* "http://www.kazmier.com/computer/snippet.el":snippets
* "http://www.webweavertech.com/ovidiu/emacs/find-recursive.txt":frecursive

*Alert:* From 0.44 release emacs-rails will require the
"inf-ruby":inf-ruby.

After that you must add this code in $HOME/.emacs

(setq load-path (cons "~/.emacs.d/rails" load-path))
(require 'rails)


== First Acquaintance

Go to directory with your rails application and open any file in Emacs:

cd $HOME/project/simple_rails_application
emacs app/controllers/application.rb

There must be "RoR" sign in the list of active minor-modes in status
bar. Thi means, that emacs-rails is enabled and ready to help you in
your not so easy work.

------------------------------------

とでてくるので

必要なファイルを取得する。

#cd ~/.emacs.d/rails

#wget http://www.kazmier.com/computer/snippet.el

#wget http://www.webweavertech.com/ovidiu/emacs/find-recursive.txt


で、

README

にあるように


#vi ~/.emacs

------------------------------------

(setq load-path (cons "~/.emacs.d/rails" load-path))
(require 'rails)

------------------------------------

を追加する。



README

に従って

rails アプリケーション
のルートディレクトリ
に移動して

------------------------------------
emacs app/controllers/application.rb
------------------------------------

のように
ファイルを指定して起動する。



アクティブファイルのステータスバーに

"RoR"

の表示が出ていれば

emacs-rails

が有効になっている。

小生は、

jruby で動作させているが

問題なく動作するようだ。

Railsレシピブック 183の技/高橋 征義

¥2,940
Amazon.co.jp

実践 Rails ―強力なWebアプリケーションをすばやく構築するテクニック/Brad Ediger

¥3,150
Amazon.co.jp

10日でおぼえる Ruby on Rails入門教室/arton

¥2,940
Amazon.co.jp

Twitter もどきを JRuby on Rails で書いてみる Part7

などのエントリで
ruby

emacs

使っている。


emacs-rails
というのが
あるそうなので
入れてみることに。

まずは、
ruby-mode
のセットアップ。

#wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.bz2
#tar -jxf ruby-1.8.7-p249.tar.bz2
#cd ruby-1.8.7-p249/misc
#less README

-------------------------
README this file
inf-ruby.el program to run ruby under emacs
ruby-mode.el ruby mode for emacs
rubydb2x.el ruby debugger support for emacs 19.2x or before
rubydb3x.el ruby debugger support for emacs 19.3x or later
ruby-electric.el emacs minor mode providing electric commands

Check out http://rubyforge.org/projects/ruby-debug/ also.
-------------------------

#sudo cp *.el /usr/share/emacs/site-lisp/

#vi ~/.emacs

で以下を追加。

-------------------------
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
(setq auto-mode-alist
(append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))

-------------------------

ここまでは、
ruby-mode
のセットアップ。

emacs-rails
については
また次回。