Skip to content

Instantly share code, notes, and snippets.

@alexgian
alexgian / x-11device.part.scm
Created February 25, 2021 21:55
The X11 device primitives that MIT-Scheme makes available for graphing
;;;; X11 graphics device
(define (initialize-package!)
(set! x-graphics-device-type
(make-graphics-device-type
'x
`((available? ,x-graphics/available?)
(clear ,x-graphics/clear)
(close ,x-graphics/close-window)
(color? ,x-graphics/color?)
@alexgian
alexgian / S3-oop-tuples.R
Last active September 4, 2018 23:45
A trivial example of Sussman's up/down tuples in R (not recursive yet)
# use R OOP (S3) to implement up/down tuples
# (as per GJS and SICM)
library(purrr)
# constructor
new_Struct <- function(stype , vec){
stopifnot(is.character(stype)) # enforce up | down
stopifnot(is.vector(vec))
structure(vec,class="Struct", type=stype)
@alexgian
alexgian / extra_slib_guile-2.2.patch
Last active August 3, 2018 13:36
Patch to allow SLIB to work under Guile 2.0 (from Chris Vine - 2.0 won't work for 2.2 - use as appropriate)
;; extra patch for 2.2 from Chris Vine (the one below is not enough)
;; not tested yet
--- guile-2.init.20 2018-06-14 10:42:46.393772164 +0100
+++ guile-2.init 2018-06-14 10:43:51.672814892 +0100
@@ -171,8 +171,6 @@
provide
provided?))
-(define slib-module (current-module))
-
@alexgian
alexgian / poly.scm
Created June 14, 2018 03:40
JACAL's polynomial routines (Aubrey Jaffer-MIT)
;; JACAL: Symbolic Mathematics System. -*-scheme-*-
;; Copyright 1989, 1990, 1991, 1992, 1993, 1995, 1997 Aubrey Jaffer.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
@alexgian
alexgian / structures.rkt
Last active June 12, 2018 19:28
Implements the up/down tuple structured objects used by scmutils/SICM, for Racket
#lang racket
(require
srfi/1
math
racket/struct
;; syntax stuff
(for-syntax
syntax/parse
syntax/parse/lib/function-header))
@alexgian
alexgian / simply_redef.scm
Last active March 26, 2023 16:13
Allows the code in the book "Simply Scheme" to run on Racket.
#lang scheme/base
;;; ============================================================================
;;; Port of the "Simply Scheme" book code to allow use under Racket
;;; ============================================================================
;;; It allows re-defining of module functions, which was the main obstacle
;;; to its operation previously.
;;; The first part is an adaptation of the necessary changes to run on Racket
;;; by importing aliased existing module functions using "require" and "only-in"
;;; The second part is the (slightly adapted) code from