Skip to content

Instantly share code, notes, and snippets.

@aijony
aijony / floating.lisp
Last active April 2, 2022 02:36
Simple Floating Class
;;;; Floating
;; See https://github.com/aijony/coalton/tree/simple-float
(coalton-toplevel
(define-class ((Dividable :a :a) (Num :a) => Floating :a)
"Common floating point operations."
(pi :a)
(sqrt (:a -> :a))
;; a ** x = exp(x log(a))
@aijony
aijony / integrate.py
Last active June 2, 2018 05:10
Integrate template, replace the 0's
def __init__(self, xMin, xMax, N):
# Define class variables
self.xMin = xMin
0
0
self.deltax = 0
# Define class function
@aijony
aijony / notmuch-fix.el
Created December 23, 2017 06:32
Notmuch keybindings fix
(defun notmuch/switch-keys (keymap keyslist)
"Swaps OLDKEY with NEWKEY in KEYMAP without changing the
key's definition"
(dolist (keys keyslist)
(let ((oldkey (car keys))
(newkey (car (cdr keys))))
(define-key keymap (kbd newkey) (lookup-key keymap (kbd oldkey)))
(define-key keymap (kbd oldkey) nil))))
@aijony
aijony / leastSquaresTrials.py
Created November 12, 2017 16:22
Minumum Least Squares Through Trial and Error
data = [(0, 0), (1, 2), (2, 4), (3, 6), (4, 8)]
m = 0
b = 0
def testFunc(x):
return m * x + b
def leastSquares(func, data):
results = 0
for datum in data:
@aijony
aijony / leastSquaresTrials.py
Created November 12, 2017 16:22
Minumum Least Squares Through Trial and Error
data = [(0, 0), (1, 2), (2, 4), (3, 6), (4, 8)]
m = 0
b = 0
def testFunc(x):
return m * x + b
def leastSquares(func, data):
results = 0
for datum in data:
from sage.symbolic.expression import is_Expression, is_SymbolicEquation
def name(func_name, expr):
r"""
Name a an unnamed symbolic function or expression.
INPUT:
- ``func_name`` -- string (default: 1) The to be given name
if the function