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
| ; https://z0ltan.wordpress.com/2018/08/04/simple-expression-evaluator-comparison-between-haskell-rust-and-common-lisp/ | |
| ; this version: 2018, Rainer Joswig, joswig@lisp.de | |
| ; 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) |
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
| ; adapted from https://groups.google.com/d/msg/comp.lang.lisp/TsmbsOK32DM/9Q7prvFV9YsJ , Pascal Costanza | |
| ;;;; checking CLOS slot writes at runtime for the correct type | |
| ;;; LispWorks | |
| (defclass slot-writes-checking-class (standard-class) | |
| ()) | |
| (defmethod validate-superclass |
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
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; Common Lisp Maze 20030311 by Joe Wingbermuehle | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; https://github.com/joewing/maze/blob/master/maze.lisp | |
| ; Changes Rainer Joswig, joswig@lisp.de, 2018 | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; Interface: the width and height of the maze. Both must be odd. |
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
| ; A MICRO-MANUAL FOR LISP - NOT THE WHOLE TRUTH, 1978 | |
| ; John McCarthy, Artificial Intelligence Laboratory, Stanford University | |
| ; https://www.ee.ryerson.ca/~elf/pub/misc/micromanualLISP.pdf | |
| ; https://github.com/jaseemabid/micromanual | |
| ; for CL : Rainer Joswig, joswig@lisp.de | |
| ; this version runs in a Common Lisp |
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
| ;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Author: joswig@lisp.de; Coding: latin-1; Base: 10; Readtable: CL -*- | |
| ; Shakesperian insults by Jerry Maguire | |
| ; Lisp code: Rainer Joswig, 2018, joswig@lisp.de | |
| (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" |
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
| ; https://codereview.stackexchange.com/questions/215682/occurrences-frequency-count-exercise-3-ch-3-in-ansi-common-lisp/215711?noredirect=1#comment417480_215711 | |
| (defun occurrences (list) | |
| (let ((ht (make-hash-table))) | |
| (let ((holder nil)) | |
| (dolist (x list) | |
| (if (not (member x holder :test #'eq)) | |
| (progn | |
| (push x holder) |
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
| ; https://github.com/netb258/clj-maze/blob/master/src/maze/core.clj | |
| ; CL version, by Rainer Joswig, joswig@lisp.de, 2019 | |
| ; changes | |
| ; maze is a 2d array, contents are symbols/numbers | |
| ; pass directions as symbols | |
| ; use paths as position histories |
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
| ;;; https://www.quora.com/Do-C-developers-find-multiple-inheritance-a-useful-feature-Do-Java-developers-ever-find-themselves-wishing-Java-supported-it/answer/Mario-Galindo-Queralt | |
| ; Common Lisp: Rainer Joswig, joswig@lisp.de, 2019 | |
| ;;; ====================================================== | |
| ;;; Features | |
| (defclass walk () |
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
| ;;; Paper: https://arxiv.org/pdf/2001.02491.pdf | |
| ;;; Code: https://github.com/cvlab-epfl/n-queens-benchmark | |
| ;;; Lisp Code: https://github.com/cvlab-epfl/n-queens-benchmark/blob/master/code/queens.lisp | |
| ;;; Changes/extensions to the original Common Lisp code: Rainer Joswig, joswig@lisp.de, 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 |
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
| ; https://leetcode.com/problems/fair-candy-swap/ | |
| (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)))) | |
| a)) |