Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Sam Ritchie sritchie

🎯
Focusing
View GitHub Profile
View sections.cljc
;;
;; Copyright © 2022 Sam Ritchie.
;; This work is based on the Scmutils system of MIT/GNU Scheme:
;; Copyright © 2002 Massachusetts Institute of Technology
;;
;; This 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.
;;
View dphi.clj
(/ (+ (* -1.35E9
'v_theta
'v_phi
(Math/pow (Math/sin 'theta) 2.0)
(Math/cos 'theta)
(Math/pow (Math/cos 'phi) 2.0))
(* 6.75E8
(Math/pow 'v_phi 2.0)
(Math/pow (Math/sin 'theta) 3.0)
(Math/sin 'phi)
View eq.clj
(clojure.core/fn
[[y47090 y47091 y47092 y47093 y47094]
[p47095 p47096 p47097 p47098 p47099]]
(clojure.core/let
[G0000000000000020
(Math/pow y47094 2.0)
G0000000000000022
(Math/cos y47091)
G0000000000000024
(Math/pow p47097 2.0)
View full_error.clj
------ ERROR -------------------------------------------------------------------
File: /Users/sritchie/code/clj/programming-2022/src/demo/viewers.cljs:12:16
--------------------------------------------------------------------------------
9 | @sv/!sci-ctx
10 | {:namespaces {'demo.face
11 |
12 | (sci/copy-ns demo.face (sci/create-ns 'demo.face))}})
----------------------^---------------------------------------------------------
Encountered error when macroexpanding sci.core/copy-ns.
NullPointerException: Cannot invoke "clojure.lang.IFn.invoke(Object)" because the return value of "clojure.lang.Var.getRawRoot()" is null
View warnings.clj
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes.uniquify, being replaced by: #'clojure.tools.analyzer.utils
View error.clj
error in process sentinel: Could not start nREPL server: Retrieving io/github/nextjournal/clerk/0.5.346/clerk-0.5.346.pom from clojars
Retrieving lambdaisland/uri/1.10.79/uri-1.10.79.pom from clojars
Retrieving org/apache/maven/resolver/maven-resolver-api/1.4.1/maven-resolver-api-1.4.1.pom from central
Retrieving org/apache/maven/resolver/maven-resolver/1.4.1/maven-resolver-1.4.1.pom from central
Retrieving org/apache/maven/resolver/maven-resolver-spi/1.4.1/maven-resolver-spi-1.4.1.pom from central
Retrieving org/apache/maven/resolver/maven-resolver-util/1.4.1/maven-resolver-util-1.4.1.pom from central
Retrieving org/apache/maven/resolver/maven-resolver-impl/1.4.1/maven-resolver-impl-1.4.1.pom from central
Retrieving org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.pom from central
Retrieving org/slf4j/slf4j-parent/1.7.29/slf4j-parent-1.7.29.pom from central
Retrieving io/github/nextjournal/clerk/0.5.346/clerk-0.5.346.jar from clojars
View mathbox_3d_require.clj
;; # Custom Viewers with d3-require
^{:nextjournal.clerk/visibility #{:hide-ns}}
(ns mathbox-d3-require
(:require [nextjournal.clerk :as clerk]))
;; This is a custom viewer for a cube rendered
;; with [Mathbox](https://gitgud.io/unconed/mathbox). Note that Mathbox isn't
;; bundled with Clerk but we use a component based
;; on [d3-require](https://github.com/d3/d3-require) to load it at runtime.
View ob-mit-scheme.el
;;; ob-mit-scheme.el --- Babel Functions for Scheme -*- lexical-binding: t; -*-
;;;
;;; Modification by Sam Ritchie to get this working with mit-scheme and the
;;; scmutils library.
;;; Requirements:
(require 'ob)
(require 'ob-scheme)
(require 'xscheme)
View poly.md

I did a bunch of work months ago on the polynomial and rational function namespaces; now they can both participate in all of the generic functions, including derivatives and all arithmetic.

I realized today that I could use an ACTUAL polynomial instance in that wacky "find-path" example from pages 22-23 of SICM. Everything is way faster and makes more sense, since find-path returns an actual polynomial.

This function generates a polynomial by passing the (identity) polynomial into the Lagrange interpolation code:

View polynomial_interpolation.clj
;; Polynomial interpolation in Clojure, written as a fold.
;;
;; This allows you to generate an estimate of the value of some polynomial at x,
;; where you have a sequence of points that the polynomial has to pass through.
;;
;; See [this namespace](https://github.com/sicmutils/sicmutils/blob/main/src/sicmutils/polynomial/interpolate.cljc#L20)
;; for a much longer build-up to these simple functions!
(defn prepare [[x fx]]
[x x fx fx])