SBCL is a high performance Common Lisp compiler.
You need to run the commands as super user (root)
;; list to string | |
CL-USER> (map 'string (lambda (x) (char (write-to-string x) 0)) '(1 2 3)) | |
"123" | |
;; string to list | |
CL-USER> (map 'list (lambda (x) (intern (string-upcase (string x)))) "lisp") | |
(L I S P) |
SBCL is a high performance Common Lisp compiler.
You need to run the commands as super user (root)
;;;; Condition Handler | |
;;;; The macro HANDLER-CASE establishes this kind of condition handler. | |
;;;; The basic form of a HANDLER-CASE is as follows: | |
;;;; (handler-case expression | |
;;;; error-clause*) | |
;;;; where each error-clause is of the following form: | |
;;;; (condition-type ([var]) code) |
;;;; The Standard Method Combination | |
(defclass book () | |
((name :accessor book-name | |
:initarg :book-name))) | |
;;; Create an object | |
(defparameter *book* (make-instance 'book | |
:book-name "The Art of the Metaobject Protocol")) |
(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" |
<!DOCTYPE html> | |
<html lang="es"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Syntax highlighting for the Web</title> | |
<!-- highlight--> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/styles/rainbow.min.css"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"> |
(in-package :postmodern) | |
(defvar *db-parameters* '("my_database" "lisp_user" "your-secret" "localhost" :POOLED-P T) | |
"Information about the connection of database.") | |
(defparameter *my-fruit* nil | |
"This var will has an object of fruits.") | |
;;; Define the macro to connect to the postgresql server | |
(defmacro with-database (&body query) |
;;; A generic function specifies only the interface. | |
;;; It performs a high-level operation. | |
;;; Generic functions are functions that behave differently | |
;;; depending on the type and identity of the arguments. | |
(defgeneric say-type-of-object (x) | |
(:documentation "It displays the type of an object.")) | |
;;; The implementation of a generic function does not exist in one place; it | |
;;; is distributed across a set of methods. |
(defun copy-a-file (origin-path new-path) | |
"Copy a file" | |
(let ((value-from-read-byte nil)) | |
;; create a stream which reads a file | |
(with-open-file (origin-file origin-path :direction :input | |
:element-type 'unsigned-byte) | |
;; create a stream which write into a file | |
(with-open-file (new-file new-path :direction :output | |
:element-type 'unsigned-byte | |
:if-exists :supersede) |
(defparameter *line* nil "This is a global variable") | |
;;; an example | |
(with-open-file (file "/tmp/myfile.txt" :direction :input) | |
(loop | |
;; gets a line from the file | |
(setf *line* (read-line file nil)) | |
(if *line* | |
;; print the lines stored in the text file | |
(format t "~% ~a ~%" *line*) |