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
| ;Test if a number is prime or NOT. | |
| ;Adrian Statescu <mergesortv@gmail.com> | |
| ;License | |
| ;MIT | |
| ;Cheers! | |
| (defun forall(L P) | |
| (if (null L) | |
| T | |
| (and (FUNCALL P (cAR L)) (forall (CDR L) P) ) |
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
| ;Project Euler Problem 3 | |
| ;Largest prime factor | |
| ;The prime factors of 13195 are 5, 7, 13 and 29. | |
| ;What is the largest prime factor of the number 600851475143 ? | |
| (defun largest (N) | |
| (setf i 2) | |
| (prog (fac) | |
| start | |
| (if (<= (* i i) 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
| ; http://thinkphp.ro | |
| ; Adrian Statescu <mergesortv@gmail.com> | |
| ; | |
| ; Sorting a list using Binary Search Tree Traversal Inorder in Common Lisp | |
| ; | |
| ; License | |
| ; MIT | |
| ; | |
| ; 9 | |
| ; 3 |
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
| ;To Count Off a List | |
| ;Adrian Statescu <mergesortv@gmail.com> | |
| ;solution using mapcar | |
| (defun countoff (L &aux (c 0)) | |
| (mapcar #'(lambda (x)(list (setf c (+ c 1)) x) ) L) | |
| ) |
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
| ;Adrian Statescu <thinkphp.ro> | |
| ;compare factorial written recursively with factorial written iteratively with prog | |
| ;i.e. 52! | |
| ;recursive | |
| (defun factorial (n) | |
| (if (= n 1) | |
| 1 |
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
| (load 'filename print T) |
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
| ;Adrian Statescu <mergesortv@gmail.com> | |
| ;(factors 8) | |
| ;(2 3) | |
| (defun factors (N) | |
| (let ((R)) | |
| (do ((x N)(c 0)(i 2 (+ i 1))) ((= x 1) R) | |
| (setf c 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
| # | |
| # Decomposition in prime factors | |
| # 10 = 2^2 * 5^2 | |
| # | |
| import sys | |
| def factors(n): | |
| i = 2 |
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
| ;Adrian Statescu <mergesortv@gmail.com> | |
| ;converts a decimal to binar | |
| (defun toBin(N) | |
| + | |
| + (let ((R)) | |
| + | |
| + (dotimes (i 15 R) | |
| + | |
| + (setf bit (logand (ash N (- i)) 1)) | |
| + |
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
| class Generate | |
| def initialize(filename) | |
| @filename = filename | |
| end | |
| def between(num, li, ls) | |