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
#!/usr/bin/env python3 | |
from PySide6.QtWidgets import ( | |
QApplication, | |
QMessageBox, | |
QWidget, | |
QLabel, | |
QPushButton, | |
QVBoxLayout, | |
QPlainTextEdit |
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
(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) |
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
(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 |
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
(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) |
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
(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) |
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
(define (product term a next b) | |
(if (> a b) | |
1 | |
(* (term a) | |
(product term (next a) next b)))) | |
(define (inc x) (+ x 1)) | |
(define (identity x) x) | |
(define (factorial n) |
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
(define (sum term a next b) | |
(define (iter a result) | |
(if (> a b) | |
result | |
(iter (next a) (+ result (term a))))) | |
(iter a 0)) |
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
(define (sum term a next b) | |
(if (> a b) | |
0 | |
(+ (term a) | |
(sum term (next a) next b)))) | |
(define (simpson-integral f a b n) | |
(let ((h (/ (- b a ) n))) | |
(define (term n) | |
(define y (f (+ a (* h n)))) |
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
(defun split-string (str &key (delimiter #\space)) | |
(defun split-string-rec (str str-list delimiter-pos) | |
(if delimiter-pos | |
(let ((current (subseq str 0 delimiter-pos)) | |
(remaining (subseq str (+ delimiter-pos 1) (length str)))) | |
(split-string-rec remaining | |
(push current str-list) | |
(position delimiter remaining))) | |
(reverse (push str str-list)))) | |
(split-string-rec str nil (position delimiter str))) |
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
const cities = ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris'].map(city => city.toLowerCase()); | |
const matches = cities.reduce((acc, curr) => { | |
const double = curr + curr; | |
const match = []; | |
cities.forEach(city => { | |
if(double.includes(city)) { | |
match.push(city); | |
} | |
}); |
NewerOlder