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
;; ProjectEuler.net | |
;; | |
;; Multiples of 3 and 5 | |
;; Problem 1 | |
;; If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
;; | |
;; Find the sum of all the multiples of 3 or 5 below 1000. | |
(defun multiple-of-p (y x) | |
(let ((r (mod x y))) |
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
; ProjectEuler.net | |
;; Even Fibonacci numbers | |
;; Problem 2 | |
;; Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: | |
;; | |
;; 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... | |
;; | |
;; By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. | |
(defun fsequence (limit) |
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
;;; Largest prime factor | |
;;; Problem 3 | |
;;; The prime factors of 13195 are 5, 7, 13 and 29. | |
;;; | |
;;; What is the largest prime factor of the number 600851475143 ? | |
;;; | |
;;; | |
(defun prime-p (x) | |
(cond ((eq 1 x) 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
;;Largest palindrome product | |
;;Problem 4 | |
;;A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. | |
;; | |
;;Find the largest palindrome made from the product of two 3-digit numbers. | |
;; | |
(defun number-palindrome-p (x) | |
(string-palindrome-p (write-to-string 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
(make-table user | |
((id serial) | |
(first-name string) | |
(last-name string) | |
(email string) | |
(phone string) | |
(image-id integer) | |
(creation-date integer (timestamp-to-unix (now)))) | |
(projects tasks) | |
(id project-id)) |
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 make-edge (from ids &key end) | |
(progn | |
(setf ids (mklist ids))) | |
(dolist (to ids) | |
(let ((lst (gethash from *edges*))) | |
(cond ((not lst) | |
(setf (gethash from *edges*) (list to))) | |
(t (if (not (member to lst)) | |
(setf (gethash from *edges*) (append lst (list to))))))) | |
(unless end (make-edge to from :end 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
angular.module('crossroadsDonateApp') | |
.directive('formItem', ['$compile', '$http', '$templateCache', function($compile, $http, $templateCache, $rootScope) { | |
var rootScope = $rootScope; | |
var getTemplate = function(contentType) { | |
var templateLoader, | |
baseUrl = 'views/', | |
templateMap = { | |
text: 'form-item-text.html', | |
radios: 'form-item-radios.html', | |
select: 'form-item-select.html', |
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 check-permission (user verb noun params) | |
(let ((verb (intern (string-upcase verb))) | |
(noun (intern (string-upcase noun)))) | |
(if (equal verb 'remove) (setf verb 'delete)) | |
(let ((perm (member noun (getf (gethash user *user-permissions*) verb) :test #'equal))) | |
(or (member (getf params :type) (getf perm noun) :test #'equal) (equal '(all) (getf perm noun)))))) |
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 insert-op (op) | |
(setf *operations* (append *operations* op))) | |
; (insert-op (create-op "mail" "mail")) | |
(defmacro create-op (noun &body body) | |
`(insert-op '((if (equal noun ,noun) | |
,@body)))) | |
; (create-op "mail" "sending mail") |
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
(defparameter echo '(lambda (x) (print x))) | |
(defun test () | |
(funcall echo "me")) | |
; (test) | |
;The value (LAMBDA (X) (PRINT X)) | |
;is not of type ; | |
;(OR FUNCTION SYMBOL). |
OlderNewer