Shammer's Philosophy

My private adversaria

Lisp

with-standard-io-syntaxってどんな意味が・・・

CommonLisp Hyper Specによれば、with-standard-io-syntaxは以下のように定義されている。 Within the dynamic extent of the body of forms, all reader/printer control variables, including any implementation-defined ones not specified by this stan…

自作concatを他パッケージで使おうとするとエラー

自作 concat - Ver20130205 - Shammerismで作成したconcatを定義したファイルを、.ccl-init.lispからloadしているが、別パッケージでこのconcatを使用するとエラーになることが判明。 ? (defpackage "P1" (:use "COMMON-LISP" "CCL" "COMMON-LISP-USER")) #<Package "P1"> </package>…

Clozure CL で load したファイルの返り値を受け取れるか

何らかの処理の書かれたファイルを読み込み、その返り値を受け取る、ということができないか試してみた。単純にloadしただけでは、ファイルのPATHが返されて期待した動作にならなかった。 ? (defparameter x (load "/tmp/aaaa.lisp")) X ? x #P"/tmp/aaaa.li…

Check valuables when ClozureCL Debugger launched

Running some functions on ClozureCL, errors are sometime happened and debugger is launched like below. ? (defvar *global* 99999) *GLOBAL* ? (format t *global*) > Error: The value 99999 is not of the expected type STRING. > While executing:…

ClozureCL Debugger :R

When compiling lisp source code based on the ClozureCL, some error happened by miss-coding. At that time, the following message like below output. > Error: There is no package named "CORE-CONSTANT" . > While executing: CCL::%PARSE-TOKEN, i…

Emacs SLIME configuration on Mavericks

I tried SLIME configuration on Debian wheezy before, but I couldn't. I write this try as SLIME Configuration on my Debian - Shammerism. I tried SLIME configuration again on my Mavericks, and finished without problems. ;;; SLIME (load (expa…

Power Up SBCL CGI

I wrote a simple CGI script with SBCL in this article. But, I would like to include the host information into the http response. Then, I modified a little bit from above article implementation. Here is a new version. #!/usr/bin/sbcl --scri…

Hello World with SBCL CGI

This is the most simple CGI with SBCL. CGI source code is like below. #!/usr/bin/sbcl --script (format t "Content-Type:text/plain~%~%") (format t "Hello, SBCL CGI!!!~%") Generating /usr/lib/cgi-bin/default.l with above contents. And add ex…

SBCLのシェル化

pythonなどをスクリプトで実行する際には、 $ python some-python-script.py Hello $というようになるものは、some-python-script.pyの冒頭に #!/usr/bin/env pythonとか付けてやることで、 $ ./some-python-script.py Hello $と、スクリプトそれ自体を直接…

SLIME Configuration on my Debian

Quicklisp helps us to configure SLIME. I referenced this site InstallingSlime – Clozure CL. Install Quicklisp (ql:quickload :quicklisp-slime-helper) After finished (ql:quickload :quicklisp-slime-helper), the following message are shown. To…

Lisp Packet Generator を作る・その2

この記事の続きでLisp Packet Generatorを作ってみる。手元の環境で、適当なローカルの宛先のパケットを取得した。その時のSYNパケットでやってみる。取得したパケットは以下のようになっている。 $ tshark -x -i en0 -Y "ip.addr eq 10.255.162.2 && tcp.fl…

Lisp Packet Generator を作る・その1

try tcpreplay - Shammerismでtcpreplayというのを使った。このときは取得済みパケットを再送というように行ったが、これで送信できるパケットを自分で作りたい。それに挑戦してみる。バイナリデータの書き出しはwriteでできるはず。パケットのバイナリをそ…

CLOSクラス変数インスタンス変数

LispでもJavaと同じようにクラス変数とインスタンス変数があるようだ。Javaではstaticを使った。CLOSでは、allocation で class か instance かを指定するようだ。デフォルトは instance らしい。 ? (defclass foo () ((global-x :reader get-global-x :writ…

loadするファイルで呼出可能な関数スコープ

一つのアプリケーションをインフラ部分と、その上で実行される不特定な処理とで分けたい。言ってみればミドルウェアっぽいことをしたい、というときに、不特定な処理で実行可能な、ミドルウェアで定義されたfunctionを呼出しできるかを確認したい。手始めに…

Install ClozureCL to Debian

ClozureCL can't be installed by apt-get on Debian. There is a tar.gz file of closure common lisp and using this file enables to install. The step is below. su - wget ftp://clozure.com/pub/release/1.9/ccl-1.9-linuxx86.tar.gz(Version will be…

clisp ext:*args* bug?

I could not use ext:*args* with Quicklisp. My example is consist of 2 lisp files. The first file is args.lisp, this is a copy of http://e-arrows.sakura.ne.jp/2010/11/common-lisp-script.html (defun args () #+allegro (system:command-line-arg…

Try xmls make-xmlrep

I installed xmls when I installed Quicklisp at the first time. I tested this. XMLS Documents I found this site, http://www.quicklisp.org/beta/UNOFFICIAL/docs/xmls/doc/index.html. This seems to be UNOFFICIAL document. I found this site too,…

Access Hunchentoot via mod_proxy

Hunchentoot document introduce how to access Hunchentoot behind a proxy. I tested this by Apache proxy.Mac OS X apache configuration files are based on /etc/apache2/httpd.conf. This file includes content from /etc/apache2/other/*, the foll…

ClozureCLでHunchentootを動かす

Quicklisp をインストール後、以下を実行する。 (ql:system-apropos "hunchentoot") (ql:quickload "hunchentoot") (in-package :hunchentoot) (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242) とりあえず、ここまで実施したら、…

ClozureCL Quicklisp initialization

This is a copy from Quicklisp beta. Get quicklisp.lisp by curl -O http://beta.quicklisp.org/quicklisp.lisp. Launch clozure common lisp by ccl or ccl64 command at the directory where quicklisp.lisp is saved. ccl64 --load quicklisp.lisp, lau…

write html file with cl-markup

There is a manual about cl-markup. GitHub - arielnetworks/cl-markup: Modern markup (HTML) generation library for Common LispThere is a clue about changing output-stream. Based on this information, I tried following code and succeeded to ge…

cl-markup library

I found the library which helps writing html in lisp, that library is cl-markup. To use this library, execute the following commands. (ql:quickload "cl-markup") (defpackage html-sample (:use :cl :cl-markup)) (in-package :html-sample) The a…

multiple-value-bindを使用せずに複数の返り値を処理する

multiple-value-bindで取得した変数を無視する - Shammerismの別バージョン。declareで無視させるのではなく、そもそも受け取る値を選択するバージョン。何度もdecode-universal-timeを呼出すので効率はよくなさそうだ。かと言って、これを一度実行して let …

multiple-value-bindで取得した変数を無視する

ファイルのタイムスタンプを取得【その3】 - Shammerismで時間を取得する関数を書いた。multiple-value-bindの戻り値で実際は使用しないだろうと思われるが返される値を取捨選択する方法がわからないのでそのまま全部受け取っているが、実際は使用されない…

Lispで挿入ソート・完

Lispで挿入ソート・その2 - Shammerismで改良したinsert-elementを使用してinsert-sort関数を書いてみた。並べ替え条件と、元リストを渡せばソートした結果を返してくれる、という動き。 ? (defun insert-sort (test org) (format t "Original List is ~A~%"…

Lispで挿入ソート・その2

Lispで挿入ソート・その1 - Shammerismで作成した ins-list を少し改良。比較が常に ? (defun insert-element (test element l) (if (null l) (cons element nil) (let ((first-element (car l))) (if (funcall test element first-element) (append (cons e…

Lispで挿入ソート・その1

挿入ソートというアルゴリズムがあるらしい。定番アルゴリズムを徹底理解! | 日経 xTECH(クロステック)これをLispでやってみようと思う。オリジナルのリストと、ソート済みのリストの双方を用意しなければできなそうだ。流れは以下のような感じだろうか。…

declareとは

たまに人が書いたLispのコードを見ると、declare というのを使っている。CLHSの解説は以下だが A declare expression, sometimes called a declaration, can occur only at the beginning of the bodies of certain forms; that is, it may be preceded only…

LispでList分割

divideとかsplitとかseparateとか、思い付いたそれっぽいキーワードで探してみたがなさそう。ありそうだけれども。Lisp で乱数リストを作る - Shammerismで書いたように、アルゴリズムのおさらいをしようとしているので、このリストの分割ができる関数が重要…

Lispではcontinueを使えない?

continueとは ループ処理の途中で、処理を一巡送りするキーワードでContinueというのがある。例えば、Javaでは以下のように使用する。 public void do() for( int i = 0 ; i < 10 ; i++ ){ if( i == 5 ){ continue; } System.out.println(i); } } こう書くと…