Lisp
I wrote the contents about SLIME configuration as SLIME Configuration on my Debian - Shammerism, but it is an old one. So I re-write same contents with the latest environment. My current environment is: OS is Debian Jessie, uname -a result…
I found the link to describe the way how to handle PostgreSQL from Common Lisp application. There is a library named clsql. I have not tried it yet but this is a memo. I will try later when I can take a time.
I want to write code to check directory traversal. In other words, replace ".." with other values if strings includes "..". For example, the string "/aaa/../index.html" should be replaced with "/index.html". And I want to write this code a…
目的 Lispのパッケージで可読性が・・・ - Shammerismで、同一パッケージのソースコードを複数ファイルに分割可能とわかった。次のステップとしてアプリ・システム全体で独自のコンディションを使用してみる。個々の処理ごとに発生する可能性のあるコンディ…
パッケージを多用した際の問題点 load したファイルで in-package しているとどうなる? - Shammerismで書いた内容に近いだろうか。Lispで大きいアプリケーションを書いていると、メソッド呼出の際のパッケージ名があちこちに入ってコードが読みにくくなる。…
In the article Lisp HTTP Client handling chunked responses - Shammerism, I wrote a HTTP client which can handle chunked response. In this article, the function whose name is http-read-line uses do loop, but I would like to rewrite as recur…
I wrote this article to concatenate some character without dotimes, using with-output-to-string instead. But, I noticed more easy way to recursive function. Here is a last version. (defun str (x) (typecase x (cons (concatenate 'string (str…
Sometimes I want to add some character repeatedly like generating something depended on how many there are. For example, organizing a file name with sequence numbers which might be different length, the length of sequence number 0 is 1, bu…
I wrote is-dot-cons to check if it is a dot cons written at Is normal cons? Is dot cons? - Shammerism, but it has a bug. This function is not considered the following cons. ("100" . '(10 20 30))This is a dot cons, but cdr is not atom, so m…
There is a case to want to know that the cons is normal cons or dotted cons. In detail, the cons is like ("A" "B") or ("A" . "B"). These cons have a difference how to handle right element. If the cons is like ("A" "B"), the function cadr c…
This is a continuous article of remove-if と remove-if-not を理解する - Shammerism and find と remove-if-not - Shammerism. Lisp functions end-with -not would be deprecated in the future, so I have to get used to use functions which are not…
I wrote an HTTP client with ClozureCL, and this can handle chunked response. (defparameter *remote-host* "d.hatena.ne.jp") (defparameter *remote-port* 80) (defparameter *client-stream* nil) (defmacro connect-operation (&rest body) `(with-o…
スクリプトとして実行された場合のみ実行したいという処理をどうすればいいか。どうやらeval-whenを使用すればこれができそうに思った。過去にちょっとだけ見たことがあるようだ。パッケージ名の取得でコケた・・・ - Shammerismでちょっとだけ言及している…
I tried to install Clozure CL 1.11 into my Debian wheezy running as Xen VM. At first, I tried the way as well as Install Clozure CL 1.10 to Debian wheezy - Shammerism, but it finished with Error. root@tora2017:/usr/local/src/ccl/lisp-kerne…
Socket 通信をバイトでやりとりするときに、文字列をそのまま16進数の文字列に変換したいことがあるのでそれを書いてみた。想定では、0から9、aからfのいずれかの1文字、2文字で一つの16進数を表現すること、先頭から読み込むと先頭が1バイトの時に正確な値…
string-output-streamをサーバーで使ってみる - Shammerismを改良し、応答をファイルから読み出したデータで返すことにする。あらかじめ、x.txtという名前のファイルを用意しておく。 $ echo 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy…
format や prin1 で文字列を受け取る - Shammerismで、make-string-output-streamを使ったときの結果を書いたが、これを TCP の Server の中で使ってみたい。 受信した文字を標準出力に書き出すだけのサーバーは以下のようになるが、 (with-open-socket (ser…
I wrote some functions that need to check the type of valuable with using cond with numberp, stringp, characterp etc, here is a sample. (cond ((numberp x) ; do something here ...) ((stringp x) ; do something here ...) (t ...)) But, there i…
There are a lot of cases that waiting user input from STDIN after show some messages. Terminal output likes below on that case. What your name?: Waiting user input can be done with read or read-line on Lisp, but we have to use other functi…
どのように呼べばいいかわからないのでこういうタイトルにしてみた。何らかの入力を伴うプログラムで、無効な値が入力された際には有効な値が入力されるまで繰り返し入力を促したい、という場合がある。全て網羅するのは大変なので、手始めに項番と項目のペ…
I found a wonder point on Lisp. Comparing a valuable type returned unexpected result. This unexpected thing happened when comparing the type of 1 and 2. I expected the type of them is equal. But this is not correct. ? (equal (type-of 1) (t…
I have thought that there are any lisp standard function to judge whether this is running as an compiled program or running as an script on interpreter, this is in this article. Although I have never looked for a such kind of function earn…
This is like a seq of shell command which is used like below. $ for i in `seq 1 10`;do echo $i;done 1 2 3 4 5 6 7 8 9 10 $Here is a lisp code. (defun seq (start end) (declare (integer start) (integer end)) (loop for i from start to end col…
I installed Clozure CL 1.9 to Debian wheezy before, detail is Install ClozureCL to Debian - Shammerism, but Clozure CL 1.10 already released. And then, I tried it but it couldn't be launched with following error. root@my-wheezy:/usr/local/…
Description I found the link in Stack Overflow discussed about this. The link is Return from a nested loop in Common Lisp - Stack Overflow. This is an continuous article of 【LISP繰り返し Hack 】do を展開してみる・その2 - Shammerism. This…
Land of Lisp を ClozureCL で - Shammerismで言及したLand of Lispだが、最初のプログラムは数当てゲームだった。1から100の中の任意の数をユーザーが決定し、コンピュータの示した数の方が大きい場合は「より小さく」という主旨のコマンドを、コンピュータ…
Lispについての本は少ない。見つけても結構古い。20世紀の本もチラホラあるくらいだ。使っていない人からしたら化石と思われていそうなそんな言語だが、オライリーからLand of Lispなる本が出た。 Lispを使う人間としては当然"買い"な本だが、残念なことに(?…
LISP IO Samples 20120825 - Shammerismに一部追加。 File 読み込み (with-open-file (input-stream "$READ_FILE_NAME" :direction :input) (loop (let ((line (read-line input-stream nil 'eof))) (if (eql line 'eof) (return)) (format t "~A~%" line)))…
そのままズバリな名前の関数ではなかったのでメモ。ashという関数を使用する。 ? (ash 32 5) 1024 ? (ash 23 2) 92 ? (ash 32 1) 64 ? (ash 64 -1) 32 ? (ash 32 -5) 1 ? (ash 32 -6) 0 ? (ash 32 -7) 0 ? ashは引数を二つ取る。一つはもとになる数(この数に…
普通にformatを使ってファイルに~%を書き出そうとすると、~%でなく改行と認識されてしまい期待通りにならない。 ? (with-open-file (file "aaa.l" :direction :output) (format file "~%")) NIL ? これで書き出されたaaa.lは以下のように改行だけ(何も表示さ…