Archive for the ‘imported kotee.freeblog.hu’ Category
New stuff.
I duplicate an element like this:
afroid-laptop% cat cikl.bf , [ > + > + << - ] >.>. > ++++++++++ . end of line afroid-laptop% echo a | bf cikl.bf aa afroid-laptop%
Medicine works with correlations. This is good as every experimental science works with them. People having a certain type of cancer, which is a well defined situation, often die in two years, which is also a well defined state. If you have a certain symptom it correlates with the possible causes known by the medical community. But everybody knows that correlation doesn’t have much in common with causality. The latter is stronger.
If you have a certain symptom A and the doctor have information about correlations with B, C and D and B have the highest score (in absolute value) then he or she will, for the first time, try avoiding B. Than C. Than D. Then who knows : )
Let’s see in practice.
- I’ve trouble with my lungs.
- Do you smoke?
- I do.
- Give up smoking then.
It’s too expensive or time consuming to figure out other possibilities.
In general I honor and respect doctors. It is a wonderful and difficult job.
Let’s see correlation again. So I said A have a strong correlation with B. Let’s suppose avoiding B helps, but not solves the problem. There will be some other effect which will be another symptom. Here we go again. And our case can be worse. Perhaps avoiding B changes the problem which isn’t the previous any more.
This is crazy (quote from comp.lang.lisp):
CL-USER> (defmethod fib ((n (eql 0))) 1)
#<STANDARD-METHOD FIB ((EQL 0)) {486206CD}>
CL-USER> (defmethod fib ((n (eql 1))) 1)
#<STANDARD-METHOD FIB ((EQL 1)) {4871255D}>
CL-USER> (defmethod fib (n)
(let ((answer (+ (fib (- n 1))
(fib (- n 2)))))
(defmethod fib ((x (eql n))) answer)
answer))
#<STANDARD-METHOD FIB (T) {488E12B5}>
CL-USER> (fib 100)
573147844013817084101
It MEMOIZEs the methods : )
One can represent a graph of objects in REPL:
CL-USER> (defmacro link (a b) `(push (lambda () ,b) (cdr ,a)))
LINK
CL-USER> (defmacro new (n o) `(defvar ,n ,o))
NEW
CL-USER> (new *h1* '(1))
*H1*
CL-USER> *h1*
(1)
CL-USER> (new *h2* '(2))
*H2*
CL-USER> *h2*
(2)
CL-USER> (link *h1* *h2*)
(#<FUNCTION (LAMBDA #) {ACE38AD}>)
CL-USER> *h1*
(1 #<FUNCTION (LAMBDA #) {ACE38AD}>)
CL-USER> (funcall (second *h1*))
(2)
CL-USER> (defun succs (n) (mapcar #'funcall (cdr n)))
SUCCS
CL-USER> (succs *h1*)
((2))
CL-USER> (link *h2* *h1*)
(#<FUNCTION (LAMBDA #) {ADFF51D}>)
CL-USER> (succs *h1*)
((2 #<FUNCTION # {ADFF51D}>))
CL-USER> (link *h1* *h1*)
(#<FUNCTION (LAMBDA #) {AE2E13D}> #<FUNCTION (LAMBDA #) {ACE38AD}>)
CL-USER> (succs *h1*)
((1 #<FUNCTION # {AE2E13D}> #<FUNCTION # {ACE38AD}>)
(2 #<FUNCTION # {ADFF51D}>))
CL-USER> *h2*
(2 #<FUNCTION (LAMBDA #) {ADFF51D}>)
CL-USER> (setf (car *h2*) '(1 2 3))
(1 2 3)
CL-USER> *h2*
((1 2 3) #<FUNCTION (LAMBDA #) {ADFF51D}>)
CL-USER> (succs *h1*)
((1 #<FUNCTION # {AE2E13D}> #<FUNCTION # {ACE38AD}>)
((1 2 3) #<FUNCTION # {ADFF51D}>))
(defun compose (&rest funs)
(if (null funs)
(lambda (k) k)
(lambda (k)
(funcall (car funs)
(funcall (apply #'compose (cdr funs)) k)))))
CL-USER> (funcall (compose (lambda (k) (* k 2)) (lambda (k) (sqrt k))) 2) 2.828427 CL-USER> (funcall (compose (lambda (k) (* k 2))) 2) 4 CL-USER> (funcall (compose) 2) 2 CL-USER>
One can reverse the pages of a PDF document by using the pdftk package under linux and fire a command like this:
pdftk input.PDF cat end-1 output output.PDF
My first hunchentoot page setup:
% pwd
/home/kotee
% ls -d slime
slime
% ls slime/slime.el
slime/slime.el
% cat .emacs
(set-variable 'scheme-program-name "guile")
(setq inferior-lisp-program "/usr/local/bin/sbcl")
(add-to-list 'load-path "/home/kotee/slime")
(require 'slime)
(slime-setup)
% cat .sbclrc
(require 'asdf)
(push "/home/kotee/asdfsys/" asdf:*central-registry*)
(asdf:oos 'asdf:load-op :hunchentoot)
(asdf:oos 'asdf:load-op :cl-who)
% ls -1 asdfsys/*.asd
asdfsys/acl-compat.asd
asdfsys/cffi.asd
asdfsys/chunga.asd
asdfsys/cl-base64.asd
asdfsys/cl-ppcre.asd
asdfsys/cl+ssl.asd
asdfsys/cl-who.asd
asdfsys/flexi-streams.asd
asdfsys/html-template.asd
asdfsys/hunchentoot.asd
asdfsys/hunchentoot-test.asd
asdfsys/md5.asd
asdfsys/rfc2388.asd
asdfsys/trivial-gray-streams.asd
asdfsys/url-rewrite.asd
% cat hunchen.lisp
(defpackage :first
(:use :cl :hunchentoot :cl-who :sb-ext))
(in-package :first)
(defmacro with-html (&body body)
`(with-html-output-to-string
(*standard-output* nil :prologue t)
,@body))
(defun main-page ()
(no-cache)
(with-html
(:html
(:head (:title "first page"))
(:body
(:h1 "first page")))))
(push (create-prefix-dispatcher "/first"
'main-page)
*dispatch-table*)
(defparameter *server* '())
(setf *server* (hunchentoot:start-server :port 4242))
% ls -1 asdfsys/*.asd
After this you can start emacs and start slime (ESC-x slime RET). Split the display with
C-x 2 and find the hunchen.lisp file with C-x C-f. Then type C-c C-k and finally one can open the http://localhost:4242/first page.