Skip to content

Instantly share code, notes, and snippets.

View jfacoustic's full-sized avatar

Josh Mathews jfacoustic

View GitHub Profile
(define (product term a next b)
(define (iter a result)
(if (= a b)
result
(iter (next a) (* result (term a)))))
(iter a 1))
(define (inc x) (+ x 1))
(define (identity x) x)
@jfacoustic
jfacoustic / filtered-acc.scm
Created October 14, 2020 12:19
1.33 SICP (iterative solution)
(define (filtered-acc filter combiner null-value term a next b)
(define (iter a result)
(if (> a b)
result
(if (filter a)
(iter (next a) (combiner (term a) result))
(iter (next a) result))))
(iter a null-value))
(define (prime? n)
@jfacoustic
jfacoustic / fixed-point.scm
Created October 16, 2020 12:58
1.35, 1.36 sicp
(define tolerance 0.00001)
(define (close-enough? v1 v2)
(< (abs (- v1 v2)) tolerance))
(define (fixed-point f first-guess)
(define (try guess)
(let ((next (f guess)))
(if (close-enough? guess next)
next
@jfacoustic
jfacoustic / cont-frac.scm
Last active October 17, 2020 15:37
1.37, 1.38, 1.39 SICP
(define (cont-frac n d k)
(define (loop i k)
(if (= k i)
(/ (n i) (d i))
(/ (n i) (+ (d i) (loop (+ i 1) k)))))
(loop 1 k))
; 1.37
(define golden-ratio 1.61803398875)
@jfacoustic
jfacoustic / website_blocker.py
Created March 10, 2024 16:43
Python UI Website Blocker
#!/usr/bin/env python3
from PySide6.QtWidgets import (
QApplication,
QMessageBox,
QWidget,
QLabel,
QPushButton,
QVBoxLayout,
QPlainTextEdit