This file contains hidden or 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 find-query (query descriptions) | |
| (find query descriptions | |
| :test (lambda (q b) | |
| (interpret-query q b)) | |
| :key #'second)) | |
| (defun lookup (v bindings) | |
| (let ((result (assoc v bindings))) | |
| (if result | |
| (second result) |
This file contains hidden or 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
| (setf (logical-pathname-translations "LIB") | |
| `(("**;*" ,(make-pathname | |
| :name :wild | |
| :directory (append (pathname-directory | |
| (sys:lisp-library-directory)) | |
| (list :wild-inferiors)) | |
| :defaults (sys:lisp-library-directory))))) | |
| ; now you can use the logical pathname LIB to refer to LispWorks files: | |
| ; (compile-file-if-needed "lib:examples;editor;commands;space-show-arglist.lisp" :load t) |
This file contains hidden or 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 factors (n) | |
| (iterate | |
| (with limit = (isqrt n)) | |
| (for factor from 1 below limit) | |
| (for (values q r) = (floor n factor)) | |
| (when (zerop r) | |
| (collect factor into lows) | |
| (collect q into highs)) | |
| (finally (setf highs (reverse highs)) | |
| (when (= n (* limit limit)) |
This file contains hidden or 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 average (list) | |
| (/ (tree-reduce #'+ list) | |
| (tree-reduce #'+ list :key (constantly 1)))) | |
| (defun tree-reduce (fn tree &key (key #'identity)) | |
| (reduce fn tree | |
| :key (lambda (item) | |
| (if (consp item) | |
| (tree-reduce fn item :key key) | |
| (funcall key item))))) |
This file contains hidden or 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
| ; http://stackoverflow.com/questions/12345647/rewrite-this-script-by-designing-an-intepreter-in-racket | |
| (defmacro verti (n &body body) | |
| `(progn | |
| (loop repeat ,n | |
| do ,@body | |
| (terpri)))) | |
| (defun hori (n s) | |
| (loop repeat n do (princ s))) |
This file contains hidden or 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 random-text (string &key (n 300) (color-filter nil)) | |
| (flet ((one-of (list) | |
| (elt list (random (length list)))) | |
| (filter-colors (colors string) | |
| (loop for color in colors | |
| when (search string (symbol-name color) :test #'equalp) | |
| collect color))) | |
| (let* ((s (make-instance 'capi:output-pane)) | |
| (colors (color:get-all-color-names))) | |
| (capi:contain s :width 2000 :height 1400) |
NewerOlder