Picolisp

From Seo Wiki - Search Engine Optimization and Programming Languages
Jump to navigationJump to search

PicoLisp is an open source Lisp dialect. It runs on Linux and other POSIX-compliant systems.

Features

Its fundamental principle is "simplicity". It restricts itself to a single internal data type (cell), without giving up flexibility and expressive power. On the language level, it supports just three data types (numbers, symbols and lists), constructed from internal cells.

Because the only non-atomic data type is the linked list, many interoperable functions exist that concentrate on list processing. As a result, PicoLisp programs are often more succinct - and at the same time faster - than those of other interpreted languages (see "Examples" below). Functions are free from the restrictions that would be imposed by a compiler, and can so accept arbitrary types and numbers of arguments. Macros are needed only in rare cases.

A special feature is the intrinsic database functionality. Persistent symbols are first-class objects, they are loaded from database files automatically when accessed, and written back when modified. Applications are written using a class hierarchy of entities and relations.

Furthermore: Prolog engine and database queries, distributed databases, inlining of C language functions and native C function calls, child process management, interprocess communication, Browser GUI, internationalization.

History

Originally developed on the Apple Macintosh in the 1980s, and used in commercial application development since then. It was soon ported to MS-DOS and SCO Unix, and used mainly on Linux since 1993. Database functionality was added in the mid-1990s.

While the first versions were written in a mix of C and Assembly language, a first rewrite from scratch was done in 1999 completely in C. That version was released 2002 under the GNU GPL license.

In 2009 the 64-bit version was released, another rewrite, this time written in a generic assembler which in turn is implemented in PicoLisp.

Examples

The following program implements the "Fannkuch" benchmark, as described in the http://shootout.alioth.debian.org/u64q/benchmark.php?test=fannkuch Alioth Benchmark Suite:

#!bin/picolisp lib.l

(let (N (format (opt))  Lst (range N 1)  L Lst  M)
   (recur (L)  # Permute
      (if (cdr L)
         (do (length L)
            (recurse (cdr L))
            (rot L) )
         (let I 0  # For each permutation
            (and (ge0 (dec (30))) (prinl (reverse Lst)))
            (for (P (copy Lst)  (> (car P) 1)  (flip P (car P)))
               (inc 'I) )
            (setq M (max I M)) ) ) )
   (prinl "Pfannkuchen(" N ") = " M)
   (bye) )

This shows how expressive and succinct a PicoLisp program can be, compared to other contributions on the Alioth site.

In contrast to the stand-alone script above, this is how it looks as a function definition:

(de fannkuch (N)
   (let (Lst (range 1 N)  L Lst  Max)
      (recur (L)  # Permute
         (if (cdr L)
            (do (length L)
               (recurse (cdr L))
               (rot L) )
            (zero N)  # For each permutation
            (for (P (copy Lst)  (> (car P) 1)  (flip P (car P)))
               (inc 'N) )
            (setq Max (max N Max)) ) )
      Max ) )

Execution speed is of course lower than that of most compiled languages,about 18 minutes on a 1.0 GHz Athlon; it should be less on Alioth's Intel Q6600 machine. As that is a quad-core, it could be sped up by a factor of four by using a parallelized version:

(de fannkuch (N)
   (let (Res (need N)  Lst (range 1 N)  L Lst  Max)
      (for (R Res R (cdr R))
         (later R
            (let L (cdr Lst)
               (recur (L)  # Permute
                  (if (cdr L)
                     (do (length L)
                        (recurse (cdr L))
                        (rot L) )
                     (zero N)  # For each permutation
                     (for (P (copy Lst)  (> (car P) 1)  (flip P (car P)))
                        (inc 'N) )
                     (setq Max (max N Max)) ) )
               Max ) )
         (rot Lst) )
      (wait NIL (full Res))
      (apply max Res) ) )

External links

References

de:PicoLisp eo:Picolisp

If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...