front | p9 | b | g | λ | new | ab | qa | cat-v.org |

Links

Programming!

Programming can be a hobby. You can learn programming to write silly scripts. This page will primarily focus on hobbyist programming languages such as lisp or bash.

Why XHTML Instead of HTML?

XML is a markup language where all documents must be marked up correctly (be "well-formed"). XHTML was developed to make HTML more extensible and flexible to work with other data formats (such as XML). In addition, browsers ignore errors in HTML pages, and try to display the website even if it has some errors in the markup. So XHTML comes with a much stricter error handling.

Basics of LISP

What is lisp?

Lisp is very old language created by John McCarthy. John McCarthy showed that with only a few simple operators and the notion of a function, one can create a elegant and extensible programming language.

During winter break(2020) I learned lisp by using Common Lisp, or CLisp. Common Lisp is dynamically typed and compiled. This means that like python or javascript, variables do not have types and can be assigned any value. Because common lisp is compiled, its speed does not fall behind C or other system languages.

Seven Primitive Operators

  1. quote
  2. (quote x) returns x. Can be abbreviated as 'x. Anything that is not a quote will be evaluated as a function.


    > (quote a)

    a

    > 'a

    a

  3. atom
  4. (atom x) returns t, which means true, if the value of x is an atom or an empty list. Otherwise it returns (), which is an empty list which means false. In lisp t is an atom


    >(atom 'a)

    t

    >(atom '())

    t

    >(atom '(a b c))

    ()

    >(atom (atom 'a))

    t

  5. eq
  6. (eq x y) returns t if the values of x and y are the same atom or both empty lists. It will return a empty list other wise.

    > (eq 'a 'a)

    t

    > (eq 'a 'b)

    ()

    > (eq (atom 'a) (atom 'b))

    t

  7. car
  8. (car x) returns the first element of x. x therefore must be a list.

    (car '(a b c))

    >a

  9. cdr
  10. (cdr x) returns everything after the first element of x. x again must be a list.

    >(cdr '(a b c))

    (b c)

  11. cons
  12. (cons x y) returns the list y with x concatenated to the front of the list

    >(cons 'a '(b c)

    (a b c)

    >(cons 'a (cons 'b '(c)))

    (a b c)

  13. cond
  14. (cond (expression return_value) (expression return_value)) evaluates as follows. The expressions are evaluated in order from left to right. The process of evaluation continues until, an expression returns t. Once an expression is found to evaluate to t, the return_value is returned as the value of the whole expression.

    >(cond ((eq 'a 'b) 'first) (atom 'a 'second))

    second

Images

XHTML screenshot


LISP screenshot


LISP Trooper