Skip to content

Instantly share code, notes, and snippets.

View informatimago's full-sized avatar

Pascal J. Bourguignon informatimago

View GitHub Profile
(defun foo (a b)
(zerop (mod (- a b) 100)))
(defun bar (a b)
(zerop (mod (- a b) 33)))
(print
(loop :for (specifiedp expected test)
;; 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)))
(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)
;;;; -*- mode:lisp;coding:utf-8 -*-
;;;;**************************************************************************
;;;;FILE: ccl-socket-example.lisp
;;;;LANGUAGE: Common-Lisp
;;;;SYSTEM: Common-Lisp
;;;;USER-INTERFACE: NONE
;;;;DESCRIPTION
;;;;
;;;; A little demo using ccl sockets and posix I/O/
;;;;
;; https://www.axess-industries.com/casiers-consignes/armoire-casier-a-effet-personnel-p-150576-600x600.jpg
;; casier: a box protected by a lock!
(terpri) (ql:quickload :bordeaux-threads)
(defstruct casier
value
(lock (bt:make-lock)))
(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 ]
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:
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 https://github.com/informatimago/FreeRDP.git 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.
F/3:45:37[pjb@L0231342 :0.0 tmp]$ cd freerdp-test-smartcard-logon-rdp/
;; in player, instead of
(defmethod attack ((p player) (g game))
(take-damage
(nth
(get-player-action p (enemies g) "Who do you wish to attack?")
(enemies g))
(atk p)))
;; write methods doing only computing: