Skip to content

Instantly share code, notes, and snippets.


Rainer Joswig lispm

View GitHub Profile
View fair-candy-swap.lisp
(defun candy-swap (a b &aux (sa (reduce #'+ a)) (sb (reduce #'+ b)))
(mapc (lambda (x &aux (y (+ x (/ (- sb sa) 2))))
(when (member y b)
(return-from candy-swap (values x y))))
View queens.lisp
;;; Paper:
;;; Code:
;;; Lisp Code:
;;; Changes/extensions to the original Common Lisp code: Rainer Joswig,, 2020
;; * using bitvectors is faster than 'boolean' arrays (which typically aren't supported in CL)
;;; In Common Lisp
;;; * use Quicklisp
;;; * compile and load this file
View mi.lisp
; Common Lisp: Rainer Joswig,, 2019
;;; ======================================================
;;; Features
(defclass walk ()
View maze.lisp
; CL version, by Rainer Joswig,, 2019
; changes
; maze is a 2d array, contents are symbols/numbers
; pass directions as symbols
; use paths as position histories
View occurences.lisp
(defun occurrences (list)
(let ((ht (make-hash-table)))
(let ((holder nil))
(dolist (x list)
(if (not (member x holder :test #'eq))
(push x holder)
lispm / insults.lisp
Created Nov 14, 2018
Shakesperian insults by Jerry Maguire in Lisp
View insults.lisp
;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Author:; Coding: latin-1; Base: 10; Readtable: CL -*-
; Shakesperian insults by Jerry Maguire
; Lisp code: Rainer Joswig, 2018,
(defparameter *insult-data*
#(#("artless" "bawdy" "beslubbering" "bootless" "churlish" "cockered" "clouted"
"craven" "currish" "dankish" "dissembling" "droning" "errant" "fawning"
"fobbing" "froward" "frothy" "gleeking" "goatish" "gorbellied"
"impertinent" "infectious" "jarring" "loggerheaded" "lumpish" "mammering"
View mccarthy-eval.lisp
; John McCarthy, Artificial Intelligence Laboratory, Stanford University
; for CL : Rainer Joswig,
; this version runs in a Common Lisp
View maze.lisp
; Common Lisp Maze 20030311 by Joe Wingbermuehle
; Changes Rainer Joswig,, 2018
; Interface: the width and height of the maze. Both must be odd.
View check-slot-writes.lisp
; adapted from , Pascal Costanza
;;;; checking CLOS slot writes at runtime for the correct type
;;; LispWorks
(defclass slot-writes-checking-class (standard-class)
(defmethod validate-superclass
View evaluate.lisp
; this version: 2018, Rainer Joswig,
; we create a bunch of structures for the expression types
; each structure defines a constructor of the same name
; each expression knows the corresponding Lisp function
(defstruct (val (:constructor val (e))) e)
(defstruct (bop :conc-name) e1 e2 op)
You can’t perform that action at this time.