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
;;Example: | |
;; 2 + 2 + 2 | |
(apply '+ '(2 2 2)) | |
6 |
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 *spam* "million") | |
(defparameter *emails* '("Reset your password" | |
"Happy birthday" | |
"Collect your million dollars now!")) | |
(defun spam-filter (emails spam) | |
"Filter emails and returns a list with good-emails and spam-emails" | |
(let ((spam-emails nil) | |
(good-emails nil)) |
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
(defentry-point "form.html" (:application *ucw-hello-world-app*) | |
() | |
;; display the window component | |
(call-as-window 'main-window | |
:title "Bootstrap form" | |
:body (make-instance 'bootstrap-form))) | |
(defcomponent bootstrap-form () | |
()) |
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
# Programación orientada a objetos | |
# Definimos la clase llamada Dog con dos atributos y un método | |
class Dog: | |
# __init__ funcion que inicializa los valores de las propiedades del objeto | |
def __init__ (self, name, age): | |
# definimos los atributos | |
# se define la propiedad llamada name y se inicializa con el valor del parámetro | |
# propiedad parámetro |
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
(define-condition odd-number-error (error) | |
((message :initarg :message :reader message)) | |
(:report (lambda (condition stream) | |
(format stream "Ups! we have an error. ~%~a" (message condition)))) | |
(:documentation "Custom error when we encounter a odd number error.")) | |
(defun filter-oddp (sequence) | |
"Iterates over the elememets of the sequence and display | |
the odd number, and otherwise invoke a condition." | |
(dolist (x sequence) |
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
(in-package #:local-time) | |
(defun get-previous-day (&key (timestamp (now))) | |
"Returns the timestamp of the previous day of the timestamp" | |
(adjust-timestamp timestamp (offset :day -1))) | |
(defun get-next-day (&key (timestamp (now))) | |
"Returns the timestamp of the next day of the timestamp" | |
(adjust-timestamp timestamp (offset :day 1))) |
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 get-timestamp-data (timestamp) | |
"Returns a list with weekday, day, month, year and total days of the month. | |
*ISO compatible weekday number (monday=1, sunday=7) | |
*day of month | |
*numeric month | |
*year | |
*numeric total-days-of-month" | |
(let ((day-of-week nil) | |
(day nil) | |
(month nil) |
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 get-long-weekday-from-timestamp (&key (timestamp (now))) | |
"Returns a string which is the weekday." | |
(let ((long-weekday (format-timestring nil | |
timestamp | |
:format '(:long-weekday)))) | |
long-weekday)) |
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 date-compare (time-a time-b) | |
"Returns the symbols <, >, or =, describing the relationship between TIME-A and TIME-B." | |
(declare (type timestamp time-a time-b)) | |
(cond | |
((< (day-of time-a) (day-of time-b)) '<) | |
((> (day-of time-a) (day-of time-b)) '>) | |
(t '=))) | |
(defun date= (time-a time-b) | |
"Return T if date of TIME-A is equal to date of TIME-B, NIL otherwise." |
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
(in-package #:pomo) | |
(defvar *db-spec* '("my_database" "my_user" "ultra-secret-password" "localhost" :POOLED-P T) | |
"Information about the connection of the database.") | |
(defmacro with-database-connection (&body query) | |
"The connection pooler. | |
This macro establish the connection with specified database in *db-parameter* variable and execute the QUERY. | |
IN: query that representing the users' query | |
OUT: result of the query" |
OlderNewer