Hi Thorsten,

> 1. How to make, concat, and kill files (and directories) on Linux with
>    PicoLisp? Using the system functions?

For making files where you will usually use 'out', and write directly to
the file.

To concat two files, you could do:

   (out "c" (in "a" (echo)) (in "b" (echo)))

Erasing a file is not implemented as a PicoLisp function. You can simply
call 'rm'

   (call 'rm "c")

> 2. How to realize the following workflow (from Emacs, using Emacs Lisp)
>    in PicoLisp:
>    You open a text file in an Emacs buffer, goto beginning-of-buffer, do
>    a regexp-search for pattern1. Get the point position of the start of
>    pattern1, then delete all the text between beginning-of-buffer and
>    start-of-pattern1. Do another regexp-search for pattern2, get point
>    position of end-of-pattern2. Then treat end-of-pattern2 like
>    beginning-of-buffer and search for start-of-pattern3 etc.

PicoLisp doesn't have regular expressions built-in, though you can call
the C library, or do similar things with 'match'. But usually it is
easier and more efficient to use 'echo', 'from', 'till' and related
functions directly on the file:

   (call 'mv "file" "file.old")        # Save original file
   (in "file.old"                      # Read original
      (out "file"                      # Write new
         (from "pattern1")             # (assuming a fixed pattern)
         (echo "pattern2") ) )

This works only for fixed strings "pattern1" and "pattern2". For more
complicated cases, it is usually possible to search for specific
substrings and the proceed with 'char', 'line' etc. to process the data.
Another possibility is to use 'till' to read all data up to a certain
character into a list, and operate on that list with 'match' or other

So, this is in sync with the "dynamic" philosophy of PicoLisp (instead
of a "static" approach with regular expressions) by "programming" the
solution in a step-by-step refinement of the search, possibly using
'if's and 'while's, and not with a kill-all predefined regular

> 3. Is it possible to use 'prog' or 'let' with 'apply', i.e. apply a
>    whole sequence of functions instead of only one to the 'lst argument?

I'm not sure what you mean here. Perhaps it helps to know that the
mapping functions take an arbitrary number of lists? Can you give an

- Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to