image

  • フォト Amazonギフト券
    ※この時計の時刻は、閲覧しているパソコンのものであり、必ずしも正確な時間とは限りません

検索

最近のトラックバック

無料ブログはココログ

« 2008-02-26 | トップページ | 2008-02-28 »

2008-02-27

2008-02-27

ピックアップ:全雑誌休刊で“脱紙”加速 ソフトバンクの大変身, 「絞り込まないで書店に立ち寄る」という衝撃, etc...

google.com で "xfy xvcd" すると
一番目に kato の homepage が出る!4番目,8番目 に katoy の blog が出る!

http://www.google.com/search?num=100&hl=en&q=xfy+xvcd&btnG=Search
Googlecomxfyxvd_2

- http://diamond.jp/series/inside/03_01_003/
> > 全雑誌休刊で“脱紙”加速、ソフトバンクの大変身|inside|ダイヤモンド・オンライン
> ... 読者に必要な情報を、最適な手段で届ける。しかも、売り上げも増え、利益も出る。それがソフトバンクの“休刊”なのだ。...

- http://www.moongift.jp/2008/02/subversion_scripts_for_mac_os_x_finder/
> > MOONGIFT: » Finderで扱うSubversion「Subversion Scripts for Mac OS X Finder」:オープンソースを毎日紹介

- http://ke-tai.org/blog/2008/02/26/gmapstatic/
> > ke-tai.org > Blog Archive > 「Google Static Maps API」を使って携帯でGoogleマップを表示する

- http://www.apple.com/jp/news/2008/feb/26mbp.html
> > アップル、MacBookとMacBook Proの新モデルを発表

- http://d.hatena.ne.jp/ayko/20080226/p2
> > 「絞り込まないで書店に立ち寄る」という衝撃 - 犬も歩けば棒にあたる本棚

Factor 言語

Factor 言語ですこし遊んでみている。
http://factorcode.org/
>> Factor is a general purpose, dynamically typed, stack-based programming language.

Factor に含まれている テトリス を動かすことは出来た。
"tetris" run
Factortetris

スペースインベーダもあるようだが、まだ動作させられずにいる。
"space-invaders" run
すばらくすると次のエラーがでる。
Set 'rom-root' to the path containing the root of the 8080 ROM files.

google で検索すると次の情報を得た。

- http://www.bluishcoder.co.nz/2007/02/emulating-other-intel-8080-based.html
  > > Emulating other Intel 8080 Based Arcade Games

- http://www.mail-archive.com/factor-talk@lists.sourceforge.net/msg00972.html
  > > [Factor-talk] space-invaders error

- http://www.mameworld.net/maws/romset/invaders
rom データなどがある?

dll をセットしろとか、ROM データを置いて、そこを差すように変数をセットしろとか
いろいろ面倒そう。
そもそも Mac (G4) で動作するのか?

ネット上で探した、Factor スクリプトの例を試している。それを以下に紹介する。

最初は helloworld プログラムと フィボナッチ数計算の例だ。
: foo は foo というメソッド(word) の定義。
! で始まる行はコメント。定義したメソッド(word) の実行の仕方を書いている。
$ cat zzz.factor
! See http://ancient.s6.xrea.com/factor/cookbook.html#sec9
! "/Users/kato/work/src/factor/zzz.factor" run-file
! ¥ hello  edit
! ¥ fib edit

USING: kernel io math memory system ;

: hello "Hello World! Factor" print ;
! hello

: fib
    dup 3 <
    [ drop 1 ]
    [ dup 1 - fib swap 2 - fib + ]
    if ;
! 10 fib .
! [ 32 fib . ] time

次は、ファイルに乱数を書き出す例だ。
times で実行時間の計測もできるようだ。
$ cat zzz01.factor
! See http://www.wagerlabs.com/blog/2008/01/introducing-fac.html

USING: prettyprint kernel math io io.mmap io.files io.binary splitting sequences alien.c-types ;

: from-source "/dev/random" <file-reader> ;
: to-target "/tmp/floats.bin" <file-writer> ;

: dump-floats
    4000000 from-source dup >r stream-read
    to-target dup >r stream-write
    r> stream-close r> stream-close ;

: clip 1000.0 min -1000.0 max ;

: make-float le> bits>float ;

: sum-floats
    "/tmp/floats.bin" 4000000 [
        4 <sliced-groups> 0 [ make-float clip + 2 / ] reduce
    ] with-mapped-file ;

! [ sum-floats ] time
!! 7737 ms run / 76 ms GC time

: sum-floats1
    "/tmp/floats.bin" 4000000 [
        0 swap dup length 4 / swap mapped-file-address
        [ float-nth clip + 2 / ] curry each
    ] with-mapped-file ;
! [ sum-floats1 ] time
!! 1358 ms run / 27 ms GC time

最後は、 階乗計算の複数の定義だ。3通りの方法を試している。
$ cat zzz02.factor
! See http://useless-factor.blogspot.com/2007/07/factorial-101.html
!     http://useless-factor.blogspot.com/2008/02/factorial-102.html
!     http://useless-factor.blogspot.com/search/label/factor

USING: prettyprint kernel math math.ranges
       io io.mmap io.files io.binary splitting sequences alien.c-types ;

: factorial ( n -- n! )
    dup zero? [ drop 1 ] [ dup 1- factorial * ] if ;
! 10 factorial .

: factorialX ( n -- n! )
    1 [ 1+ * ] reduce ;
! 10 factorialX .

: factorialY ( n -- n! )
    [1,b] product ;
! 10 factorialY .

いずれも、java などより簡潔に記載できている。
Factor は多くの ライブラリーが用意されているし、それらのナビゲート機能もある。
(テトリスゲームがかけるぐらいには)

どう書く?.org でもいくつか Factor での解答が投稿されている。
  http://ja.doukaku.org/tag/Factor/

もうすこし、Factor で遊んでみようと思う。

« 2008-02-26 | トップページ | 2008-02-28 »

mokuji

2013年12月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

google

  • twitter
  • __
  • _
    Googleボットチェッカー

合わせて読む

  • 合わせて読む
    フィードメーター - katoy: cocolog あわせて読みたい

リンク