image

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

検索

最近のトラックバック

無料ブログはココログ

« erlang を評価中... | トップページ | 小栗旬のカリギュラを観た »

2007-11-24

swi-prolog も評価中

erlang だけでなく、別言語も試してみている。
document の複合化だけでなく、プログラミングも 複合化できるようになっていくべきなのかもしれない。

他にも haskell,  forth, APL など毛色の変わった言語も試してみる予定だ。

- http://ja.wikipedia.org/wiki/Hello_world%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%81%AE%E4%B8%80%E8%A6%A7
> > Hello worldプログラムの一覧 - Wikipedia

swi-prolog も macport でインストールした。

$ port search prolog
gprolog                        lang/gprolog   1.3.0        GNU Prolog compiler
prolog-mode.el                 lang/prolog-mode.el 1.2          An emacs major mode for editing prolog programs.
swi-prolog                     lang/swi-prolog 5.6.47       SWI-Prolog compiler plus extra packages (stable version)
swi-prolog-devel               lang/swi-prolog-devel 5.5.36       SWI-Prolog compiler plus extra packages (development version)
swi-prolog-lite                lang/swi-prolog-lite 5.6.12       SWI-Prolog compiler (without extra packages)

$ sudo port install swi-prolog

やはり、最初は Hello world と 階乗計算で。

$ cat fact.pl
% See http://www.sakalab.org/swi-prolog/swi-prolog.html

% fact.pl - basic factorial
fact(N, 1) :- N < 1, !.
fact(N, X) :- N1 is N - 1,
    fact(N1, Y),
    X is N * Y.

hello(X) :- display('Hello swi-prolog.').

$ swipl
Welcome to SWI-Prolog (Multi-threaded, Version 5.6.47)
Copyright (c) 1990-2007 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- consult('fact.pl').
Warning: (/Users/kato/work/src/prolog/fact.pl:10):
        Singleton variables: [X]
% fact.pl compiled 0.00 sec, 1,032 bytes

Yes
?- fact(10,A).

A = 3628800
?- fact(100,A).

A = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
?- hello(A).
Hello swi-prolog.

Yes
?- halt.

swipl -c file名で、compile 結果が a.out として得られる。

$ swipl -c fact.pl
Warning: (/Users/kato/work/src/prolog/fact.pl:10):
        Singleton variables: [X]
% fact.pl compiled 0.00 sec, 844 bytes
% /opt/local/lib/swipl-5.6.47/library/edinburgh compiled into edinburgh 0.01 sec, 2,032 bytes
$ ls
a.out*  fact.pl
$ ./a.out
Welcome to SWI-Prolog (Multi-threaded, Version 5.6.47)
Copyright (c) 1990-2007 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- fact(10,A).

A = 3628800
?- halt.

Amazonギフト券

« erlang を評価中... | トップページ | 小栗旬のカリギュラを観た »

コメント

この記事へのコメントは終了しました。

トラックバック


この記事へのトラックバック一覧です: swi-prolog も評価中:

« erlang を評価中... | トップページ | 小栗旬のカリギュラを観た »

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 あわせて読みたい

リンク