Skip to content

Instantly share code, notes, and snippets.

Pascal J. Bourguignon informatimago

View GitHub Profile
View function-names
(defun function-names (fun)
RETURN: A list of function names fbound to the function FUN.
NOTE: We only scan symbols and (setf symbols). Functions could also
be bound to slots or to various other lisp objects.
(let ((names '()))
(dolist (pack (list-all-packages) (delete-duplicates names))
(do-symbols (sym pack)
(when (and (fboundp sym) (eql fun (symbol-function sym)))
View test test-not
(defun foo (a b)
(zerop (mod (- a b) 100)))
(defun bar (a b)
(zerop (mod (- a b) 33)))
(loop :for (specifiedp expected test)
View reader-macro-parser.lisp
;; expression ::= term [ +|- expression ].
;; term ::= factor [ *|/ term ].
;; factor ::= simple [ ^ factor ].
;; simple ::= variable | literal | '(' expression ')' .
(defun parse-expression (stream)
(let ((term (parse-term stream)))
(if (find (peek-char t stream nil) "+-")
(let ((op (intern (string (read-char stream))))
(expression (parse-expression stream)))
View german.lisp
(in-package :cl-user)
(defun strcat (&rest strings)
(format nil "~{~A~}" strings))
(deftype german-case () `(member :nominative :accusative :dative :genitive))
(deftype german-gender () `(member :masculine :feminine :neuter))
(deftype german-number () `(member :singular :plural))
(defun definite-article (case gender number)
View ccl-socket-example.lisp
;;;; -*- mode:lisp;coding:utf-8 -*-
;;;;FILE: ccl-socket-example.lisp
;;;;LANGUAGE: Common-Lisp
;;;;SYSTEM: Common-Lisp
;;;; A little demo using ccl sockets and posix I/O/
View casier: a variable protected by a lock.
;; casier: a box protected by a lock!
(terpri) (ql:quickload :bordeaux-threads)
(defstruct casier
(lock (bt:make-lock)))
View brainfuck implementation improvement.
(defmacro instruction-case (op &body clauses)
"Maps symbolic instruction names to their internal code (characters):
move-left <
move-right >
increment +
decrement -
read ,
write .
while [
end ]
View new bash feature
Here is a nice feature; you could patch bash to do it:
every time you run a command, bash would redirect the
output automatically behind the scene. By default it
would tee it to the tty as always, but while the command
is running (and even after, from the history), we could
redirect the output to a file or a pipe, dynamically.
And conversely, when we run a pipe, we could at any time
have a look at the data going thru a pipe. For example
you would type:
View freerdp.log
This file has been truncated, but you can view the full file.
F/3:45:37[pjb@L0231342 :0.0 doc]$ cd /tmp
F/3:45:37[pjb@L0231342 :0.0 tmp]$ git clone freerdp-test-smartcard-logon-rdp
Cloning into 'freerdp-test-smartcard-logon-rdp'...
remote: Counting objects: 109847, done.
remote: Compressing objects: 100% (1546/1546), done.
remote: Total 109847 (delta 326), reused 220 (delta 15), pack-reused 108282
Receiving objects: 100% (109847/109847), 37.70 MiB | 294.00 KiB/s, done.
Resolving deltas: 100% (83201/83201), done.
Checking connectivity... done.
You can’t perform that action at this time.