This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage :monad (:use :cl :optima)) | |
(in-package :monad) | |
(defun seqM (ms) | |
(labels ((rec (ms) | |
(match ms | |
((list m) | |
(fmap m (lambda (x) (cons x nil)))) | |
((cons m ms) | |
(bind m (lambda (x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; urlencodeの実験 | |
(let ((str (map 'string (lambda (_) | |
(declare (ignore _)) | |
(code-char (random 255))) | |
(make-string (* 1024 1024))))) | |
(null (time (puri::encode-escaped-encoding str puri::*reserved-characters* t))) | |
(null (time (urlencode:urlencode str)))) | |
(in-package :urlencode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; do-urlencodeはUTF-8に変換してる分不利 | |
;; ただ、1MBの処理に1GB超は少し辛い? | |
;; 実際にそんな大きいデータを扱うことはないけど、積み重なると結構差が出そう | |
(let ((str (map 'string (lambda (_) | |
(declare (ignore _)) | |
(code-char (random 255))) | |
(make-string (* 1024 1024))))) | |
(null (time (puri::encode-escaped-encoding str puri::*reserved-characters* t))) | |
(null (time (urlencode:urlencode str)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /home/manabu/quicklisp/dists/quicklisp/software/drakma-1.2.7/request.lisp 2012-09-11 06:07:54.146125000 +0900 | |
+++ /home/manabu/work/request.lisp 2012-09-12 08:00:26.953125000 +0900 | |
@@ -663,18 +663,17 @@ | |
(when (and content-length | |
(not (or (and (integerp content-length) | |
(not (minusp content-length))) | |
- (arrayp content) | |
- (listp content) | |
+ (typep content '(or (vector octet) list)) | |
(eq content :continuation)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :cl-ppcre) | |
(ql:quickload :bordeaux-threads) | |
(ql:quickload :usocket) | |
(ql:quickload :drakma) | |
(asdf:component-version (asdf:find-system :drakma)) | |
;=> "1.2.7" | |
(flet ((echo-content () | |
(usocket:with-socket-listener (socket "127.0.0.1" 8080 :reuse-address t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :cl-user) | |
(eval-when (:compile-toplevel :load-toplevel :execute) | |
(ql:quickload :alexandria) | |
(ql:quickload :fiveam)) | |
(defpackage :sort | |
(:use :cl) | |
(:import-from :alexandria :iota) | |
(:export :bubble-sort/naive :bubble-sort/not-enough :bubble-sort/knuth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(do ((n 0 (1+ n))) | |
((= n 10)) | |
(if (zerop (mod n 5)) | |
(format t "~&~a" n) | |
(format t "~a" n))) | |
(let ((l '#1=("~&~a" "~a" "~a" "~a" "~a" . #1#))) | |
(do ((n 0 (1+ n)) | |
(l l (cdr l))) | |
((= n 10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cffi:with-foreign-object (p :pointer) | |
(print (cffi:mem-ref p :pointer)) | |
(setf (cffi:mem-ref p :pointer) (cffi:null-pointer)) | |
(print (cffi:mem-ref p :pointer)) | |
(print (cffi:pointer-address p))) | |
;-> #<A Foreign Pointer #x36> | |
; #<A Null Foreign Pointer> | |
; 37879600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foldl (kons knil &rest series-inputs) | |
(apply #'series::basic-collect-fn (constantly knil) kons series-inputs)) | |
(define-compiler-macro foldl (kons knil &rest series-inputs) | |
`(collect-fn t (constantly ,knil) ,kons ,@series-inputs)) | |
(foldl #'- 0 (scan '(0 1 2 3 4))) | |
;=> -10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; It's anaphoric if for pointers. If the first argument is NOT a null pointer, | |
;; evaluates the second argument. Otherwise evaluates third. | |
(defmacro aif/ptr (test then &optional else) | |
`(let ((it ,test)) | |
(if (null-pointer-p it) ,else ,then))) |