Juan Reynoso Elias
En 2021-05-07 11:03:21

Bootstrap 5 + UCW Examples + mod_lisp


Bootstrap 5 has officially landed! After three alphas, three betas, and several months of hard work, we’re shipping the first stable release of our new major version. It’s been a wild ride made possible by our maintainers and the amazing community that uses and contributes to Bootstrap. Thanks to all who have helped us get here!

You can download the code:


You can load the project:

CL-USER> (ql:quickload "ucw-hello-world")

CL-USER> (in-package :ucw-hello-world)

UCW-HELLO-WORLD> (start-app)

Access the pages:

Bootstrap 4



Bootstrap 5


UCW Backends

UCW can be made to work with any backend, including mod_lisp, lisp HTTP servers , or its own internal HTTPD. We'll be using the internal HTTPD.

Backend mod_lisp

In order to install mode_lisp you need to run:

aptitude install libapache2-mod-lisp 

Enable module

a2enmod lisp

Configuring Apache with mod_lisp

add the following lines in /etc/apache2.conf  file:

LispServer 8080 "ucw"

SetHandler lisp-handler

Restart apache server

/etc/init.d/apache2 restart

Start the UCW app

CL-USER> (ql:quickload "ucw-hello-world")
CL-USER> (in-package :ucw-hello-world)

UCW-HELLO-WORLD> (start-app :backend :mod-lisp)





#mod-lisp #apache #lisp #ucw

También te podría interesar

Juan Reynoso Elias
En 2016-03-29 10:42:15


All of the I/O functions in lisp accept a stream argument. In some cases (e.g. READ and PRINT) the stream argument is optional; by default, input comes from the *STANDARD-INPUT* stream (normally connected to keyboard) and output goes to the *STANDARD-OUTPUT* stream (normally connected to display).

The power of streams comes from the ability to associate a stream with a file, a device (such as keyboard, display, or network), or a memory buffer. Program I/O can be directed at will by simply creating the appropriate type of stream for your program to use. The I/O implementation is abstracted away by the stream so your program won't have to be concerned with low-level details.

Creating streams on files

The OPEN function creates a FILE-STREAM. Keyword arguments determine attributes of the stream (:DIRECTION, :ELEMENT-TYPE, and :EXTERNAL-FORMAT) and how to handle exceptional conditions (:IF-EXISTS and :IF-DOES-NOT-EXIST). If OPEN is successful it returns a stream, otherwise it returns NIL or signals an error.

Keyword      Value     Stream Direction
----------   -------   -----------------------------
:DIRECTION   :INPUT    input (default)
:DIRECTION   :IO       input & output
:DIRECTION   :PROBE    none, returns a closed stream

Keyword      Value                Action if File Exists
----------   ------------------   ---------------------------------------
:IF-EXISTS   NIL                  return NIL
:IF-EXISTS   :ERROR               signal an error
:IF-EXISTS   :NEW-VERSION         next version (or error)
:IF-EXISTS   :RENAME              rename existing, create new
:IF-EXISTS   :SUPERSEDE           replace file upon CLOSE
:IF-EXISTS   :RENAME-AND-DELETE   rename and delete existing, create new
:IF-EXISTS   :OVERWRITE           reuse existing file (position at start)
:IF-EXISTS   :APPEND              reuse existing file (position at end)

Keyword              Value     Action if File Does Not Exist
------------------   -------   -----------------------------
:IF-DOES-NOT-EXIST   NIL       return NIL
:IF-DOES-NOT-EXIST   :ERROR    signal an error
:IF-DOES-NOT-EXIST   :CREATE   create the file

Keyword         Value               Element Type
-------------   --------------      ------------------------
:ELEMENT-TYPE   :DEFAULT            character (default)
:ELEMENT-TYPE   'CHARACTER          character
:ELEMENT-TYPE   'SIGNED-BYTE        signed byte
:ELEMENT-TYPE   'UNSIGNED-BYTE      unsigned byte
:ELEMENT-TYPE   character subtype   character subtype
:ELEMENT-TYPE   integer subtype     integer subtype
:ELEMENT-TYPE   other               implementation-dependent

Keyword            Value      File Format
----------------   --------   ------------------------
:EXTERNAL-FORMAT   :DEFAULT   default (default)
:EXTERNAL-FORMAT   other      implementation-dependent

Once you've opened a stream, you can use it with appropriate input or output functions, or with queries that return attributes of either the stream or the file. The following queries can be applied to all kinds of streams. All of these accept a stream argument:

Function               Returns
--------------------   -----------------------------------------------------
INPUT-STREAM-P         true if stream can provide input
OUTPUT-STREAM-P        true if stream can accept output
OPEN-STREAM-P          true if stream is open
STREAM-ELEMENT-TYPE    the type specifier for stream elements
INTERACTIVE-STREAM-P   true if stream is interactive (e.g. keyboard/display)

These queries can be applied to file streams. These also accept a stream argument:

Function                 Returns
--------------------     -----------------------------------------------------
STREAM-EXTERNAL-FORMAT   implementation-dependent
FILE-POSITION            current file offset for read or write, or NIL
FILE-LENGTH              length of stream, or NIL

FILE-POSITION returns a byte offset within the stream. This is an exact count for streams of integer subtypes (see below for further description of binary I/O). For streams of character subtypes, the position is guaranteed only to increase during reading or writing; this allows for variations in text record formats and line terminators.

FILE-POSITION can also be called with a second argument to change the file offset for the next read or write. When used for this purpose, FILE-POSITION returns true when it succeeds.

You should always close a stream when you're done using it (except for the interactive streams provided for you use by Lisp, such as *STANDARD-INPUT*, *STANDARD-OUTPUT*, and *TERMINAL-IO*). The "open, process, close" pattern is very common, so Lisp provides macros to make the pattern both easy to code and error-free.

WITH-OPEN-FILE is tailored for file streams. Its arguments are a variable to be bound to the stream, a pathname, and (optionally) keyword arguments suitable for OPEN. The stream is always closed when control leaves the WITH-OPEN-FILE form.

(with-open-file (stream "my-file.dat" :direction :input)
  ... do something using stream ...)

WITH-OPEN-STREAM expects a variable name and a form to be evaluated; the form should produce a stream value or NIL. This macro is commonly used with constructors for specialty streams, such as MAKE-BROADCAST-STREAM, MAKE-ECHO-STREAM, MAKE-TWO-WAY-STREAM, MAKE-CONCATENATED-STREAM, and MAKE-SYNONYM-STREAM.

Finally we have an example ready to run

(defun copy-a-file ()
  "Read a file and copy to"
  (let ((value-from-read-byte nil)
    (origin-path "/tmp/my-file.jpg")
    (new-path "/tmp/my-new-file.jpg"))
    (with-open-file (origin-file origin-path :direction :input :element-type 'unsigned-byte)
      (with-open-file (new-file new-path :direction :output :element-type 'unsigned-byte :if-exists :supersede)
    ;;Here we read the origin file and writing into the new file
       ;; exit when get :eof (end of file)
       (when (equal value-from-read-byte :eof) (return nil))
       ;; reading the data
       (setf value-from-read-byte (read-byte  origin-file nil :eof))
       ;; writing the data; in other words copy a file
       (unless (equal value-from-read-byte :eof)
         (write-byte value-from-read-byte new-file)))))))

#lisp #streams

Juan Reynoso Elias
En 2018-01-17 17:43:31

Defun and Lambda

DEFUN defines a function with name

You can define a named function using the DEFUN form:
(defun sum (x y)
  (+ x y))

The defun form has the following arguments:

  • The name of the function: sum
  • A list of argument names: x y
  • The body of the function: (+ x y)

DEFUN returns the name of the defined function, so we have a sum as function.

Now we are going to review the lambda.
LAMBDA defines anonymous functions
Lisp lets you create an unnamed, or anonymous, function using the LAMBDA form:

(lambda (x y)
  (+ x y))

The lambda form has the following arguments:

  • A list of the arguments names: x y
  • The body of the lambda: (+ x y)

I ask me, how can I call or use the lambda?, well I could do this:
((lambda (x y)
  (+ x y)) 1 2)


(funcall (lambda (x y)
  (+ x y)) 1 2)

Other examples:

I have a list like this (1 2 3 4 5), so I want to add 1 all of them, then the result will be (2 3 4 5 6)
How can I do that?
We are going to use mapcar with a lambda:
(mapcar (lambda (x) (+ x 1)) '(1 2 3 4 5))

Now I have a list like this: ((9 2 7 5) (7 2 0 9) (10 1 0 21 15 )), so I want to sort the list like this ((2 5 7 9) (0 2 7
9) (0 1 10 15 21))
(mapcar (lambda (x) (sort x #'< )) '((9 2 7 5) (7 2 0 9) (10 1 0 21 15 )))

Juan Reynoso Elias
En 2017-02-25 14:05:39

Mapping is a type of iteration in which a function is successively applied to pieces of one or more sequences. The result of the iteration is a sequence containing the respective results of the function applications.

I want to a list of the list like
((1) (2) (3))
(map 'list (lambda (x) (list x)) '(1 2 3))

list to string

(map 'string (lambda (x) (char (write-to-string x) 0)) '(1 2 3))
string to list
(map 'list (lambda (x) (intern (string-upcase (string x)))) "lisp")
list to vector
(map 'vector (lambda (x) x) '( 1 2 3))
vector to string
(map 'list (lambda (x) x) #(1 2 3))
The cadr as alist
(map 'list (lambda (x)  (cons (first x) (second x))) '((1 "one") (2 "two")))

#lisp #map

Juan Reynoso Elias
En 2017-02-25 14:22:15

Hello world Uncommon Web
What is UCW?
UCW is a multi-paradigm framework for building Web based applications in Common Lisp. It has an extensible core, the RERL, that enables many methods and styles of web development, and can operate using almost any web server as a front end, including a few that come built in.

UCW includes a component oriented system allows both the graphical elements and the presentation logic to be easily reused and adapted, and has features that allow developers to write complex page flow logic as if it was a "regular" sequence of function calls.


Uncommon web provides a framework that abstracts the details of HTTP.  Understanding UCW is the simple matter of understanding theseabstractions, and how they come together to form a ucw application.

Web developers starting with UCW often have trouble understanding how it works. Its more advanced features, such as callbacks and actionsusing continuations, seem to work like magic.

If you want to try UCW as hello world you can clone the repo ucw-hello-world:



You can get the code from github


Load with quicklisp:
CL-USER> (ql:quickload "ucw-hello-world")
To load "ucw-hello-world":
  Load 1 ASDF system:
; Loading "ucw-hello-world"
CL-USER> (in-package :ucw-hello-world)
UCW-HELLO-WORLD> (start-app)


In your browser set:

#lisp #ucw
Juan Reynoso Elias
En 2019-02-15 13:17:59
Mathematics with common lisp
Maxima is a system for the manipulation of symbolic and numerical expressions, including differentiation, integration, Taylor series, Laplace transforms, ordinary differential equations, systems of linear equations, polynomials, sets, lists, vectors, matrices and tensors. Maxima yields high precision numerical results by using exact fractions, arbitrary-precision integers and variable-precision floating-point numbers. Maxima can plot functions and data in two and three dimensions.

The Maxima source code can be compiled on many systems, including Windows, Linux, and MacOS X. The source code for all systems and precompiled binaries for Windows and Linux are available at the SourceForge file manager.

Maxima is a descendant of Macsyma, the legendary computer algebra system developed in the late 1960s at the Massachusetts Institute of Technology. It is the only system based on that effort still publicly available and with an active user community, thanks to its open source nature. Macsyma was revolutionary in its day, and many later systems, such as Maple and Mathematica, were inspired by it.


I need to derivate:
                              sin (3 x)

working with maxima:

Maxima 5.38.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.12
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.

(%i1) diff (sin (3*x)^2);

(%o1) 6 cos(3 x) sin(3 x) del(x)

#lisp #maxima #emacs
step by step