Source of Nothingness - 2345

* Menu

[[About:self:AboutPage.txt]] | [[Profile:file/southly/]] | [[まとめ:self:1163859357.txt]] | [[オリジナル:http://ninjinix.x0.com/rn/]] | [[xyzzy:lisp/]] | [[あんてな:listall]] | [[■:lisp]] | [[buzz:files/southly#buzz]]

* 2007-02-21

擬似乱数生成器 Xorshift RNGs ってのを見つけた。
 http://lucille.atso-net.jp/blog/?p=9
書いてみる
(let ((x 123456789) (y 362436069) (z 521288629) (w 88675123))
  (defun xor128 ()
    (let ((a (logxor x (logand #xFFFFFFFF (ash x 11)))))
      (shiftf x y z w)
      (setq w (logxor (logxor w (ash w -19)) (logxor a (ash a -8)))))))

(dotimes (i 100)
  (format t "~8,'0x~%" (xor128)))

* xyzzy lisp : format ~F

(format nil "~F" 123.45)
"123.45"
(format nil "~@F" 123.45)
"+123.45"
(format nil "~10F" 123.45)
"    123.45"
(format nil "~10,5F" 123.45)
" 123.45000"
(format nil "~10,5,2F" 123.45)
"12345.00000"
(format nil "~10,5,2,'#F" 123.45)
"##########"
(format nil "~10,,,,'$F" 123.45)
"$$$$123.45"

* xyzzy lisp : format ~E

(format nil "~E" 123.45)
"1.2345e+2"
(format nil "~@E" 123.45)
"+1.2345e+2"
(format nil "~10E" 123.45)
" 1.2345e+2"
(format nil "~10,5E" 123.45)
"1.23450e+2"
(format nil "~10,5,2E" 123.45)
"1.23450e+02"
(format nil "~10,5,2,3E" 123.45)
"123.450e+00"
(format nil "~10,5,2,3,'%E" 123.45)
"%%%%%%%%%%"
(format nil "~15,,,,,'=@E" 123.45)
"=====+1.2345e+2"
(format nil "~15,,,,,,'D@E" 123.45)
"     +1.2345D+2"

* xyzzy lisp : format ~R

(format nil "~10,10,'*,'-,2:R" 12345)
"***1-23-45"
(format nil "~R" 12345)
"twelve thousand, three hundred and forty-five"
(format nil "~:R" 12345)
"twelve thousand, three hundred and forty-fifth"
(format nil "~@R" 1234)
"MCCXXXIV"
(format nil "~:@R" 1234)
"MCCXXXIIII"

* xyzzy lisp : format ~D


(format nil "~D" 12345)
"12345"
(format nil "~:D" 12345)
"12,345"
(format nil "~@D" 12345)
"+12345"
(format nil "~:@D" 12345)
"+12,345"
(format nil "~10D" 12345)
"     12345"
(format nil "~10,'*D" 12345)
"*****12345"
(format nil "~10,'*:@D" 12345)
"***+12,345"
(format nil "~10,'*,'-,2:D" 12345)
"***1-23-45"

* xyzzy lisp : format ~O


(format nil "~O" #o12345)
"12345"
(format nil "~:O" #o12345)
"12,345"
(format nil "~@O" #o12345)
"+12345"
(format nil "~:@O" #o12345)
"+12,345"
(format nil "~10O" #o12345)
"     12345"
(format nil "~10,'*O" #o12345)
"*****12345"
(format nil "~10,'*:@O" #o12345)
"***+12,345"
(format nil "~10,'*,'-,2:O" #o12345)
"***1-23-45"

* clispcgi

URIのデコード・エンコードが一応完成。
感想メモ
・whileが無くてびっくり
xyzzy lispとの微妙な差が気になる
・(alphanumericp #\あ) => T ってなんだよ!?

[[(ReadMore...) index.rb?1141223408.txt]]