This file contains 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
(defparameter *sieve* #<a[n] = | |
#<b[k] = (+ k 2) >, (filter-series | |
#'(lambda (val) | |
(< 0 (mod val a[n-1][0]))) | |
a[n-1])>) | |
(defparameter *primes* #<a[n] = *sieve*[n][0]>) |
This file contains 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
(defparameter *sieve* #<a[n] = | |
#<b[k] = 2, (1+ (* k 2)) >, (let ((factor a[n-1][0])) | |
(filter-series | |
#'(lambda (val) | |
(< 0 (mod val factor))) | |
a[n-1]))>) | |
(defparameter *primes* #<a[n] = *sieve*[n][0]>) |
This file contains 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 check-series-mod (target a n) | |
(cond ((< target 2) nil) | |
((= target 2) t) | |
(t (do-series (val a to (1- n)) | |
(if (= (mod target val) 0) | |
(return-from check-series-mod nil)) | |
(if (> (expt val 2) target) | |
(return-from check-series-mod t))) | |
t))) |
This file contains 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 factorize-in-prime (target &key (prime-series *prime-series*)) | |
(if (eq target 1) | |
(return-from factorize-in-prime nil)) | |
(let ((factor (lcar prime-series))) | |
(cons (loop while (= (mod target factor) 0) | |
count t | |
do (setf target (/ target factor))) | |
(factorize-in-prime target :prime-series (lcdr prime-series))))) |
This file contains 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 inverse-factorize-from-prime (target &key (prime-series *prime-series*)) | |
(if (null target) | |
1 | |
(* (expt (lcar prime-series) (car target)) | |
(inverse-factorize-from-prime (cdr target) | |
:prime-series (lcdr prime-series))))) |
This file contains 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 calc-GCD (&rest nums) | |
(inverse-factorize-from-prime | |
(bundle-lists #'min | |
(mapcar #'factorize-in-prime nums)))) | |
(defun calc-LCM (&rest nums) | |
(inverse-factorize-from-prime | |
(bundle-lists #'max | |
(mapcar #'factorize-in-prime nums)))) |
This file contains 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
#!/bin/sh | |
#|-*- mode:lisp -*-|# | |
#| | |
exec ros -Q -- $0 "$@" | |
|# | |
(defparameter *depend-on* '(:dexador :cxml)) | |
(eval-when (:execute) | |
(dolist (target *depend-on*) | |
(ql:quickload target))) |
This file contains 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
#!/bin/sh | |
#|-*- mode:lisp -*-|# | |
#| | |
exec ros +Q -- $0 "$@" | |
|# | |
(defun do-nothing (&rest rest) | |
(declare (ignore rest))) | |
(defun make-list-reader (stream &rest rest) |
This file contains 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
#!/bin/sh | |
#|-*- mode:lisp -*-|# | |
#| | |
exec ros +Q -- $0 "$@" | |
|# | |
(defun set-delimiter-with-print (char) | |
(set-macro-character char #'(lambda (&rest rest) | |
(declare (ignore rest)))) | |
(print "set delimiter")) |
This file contains 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 reconstruct-list (lst fn-elem) | |
(labels ((rec (result rest) | |
(if rest | |
(dolist (elem rest) | |
(setf result | |
(cons (if (listp elem) | |
(rec nil elem) | |
(funcall fn-elem elem)) | |
result)))) | |
(reverse result))) |
OlderNewer