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) |
;;;; 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) |
SBCL is a high performance Common Lisp compiler.
You need to run the commands as super user (root)
;;;; 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 :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*) |
# Python Object-Oriented programming | |
# Define a class called Dog | |
# Python class names are written in CapitalizedWords notation by convention. | |
class Dog: | |
# define a method called __init__ it is a special init method. | |
# "__init__" is a reseved method in python classes. It is known as a constructor in object oriented concepts. | |
# This method called when an object is created from the class and it allow the class to initialize the attributes of a class. | |
def __init__ (self, name, age): | |
# self represents the instance of the class. By using the "self" keyword. We can access the attibutes and methods of the |
/* Creates a single object, using an object literal. | |
* An object literal is a list of name:value pairs | |
(like age:36) inside curly braces {}. | |
*/ | |
let myObjectPerson = { name: 'Juan', age: 36, sayHello: function (){ | |
console.log("Hello, I am " + this.name + " and I am " + | |
this.age + " years old.");} | |
}; |