How to use the history mechanism implemented in PSL/FRL:
PSL/FRL allows you to take any previous input or output and substitute
it in place of what you typed. Thus you can either print or redo
any input you have previously done. You can also print or
execute any result you have previously received.
The system will work identify commands by either their history number,
or by a subword in the input command.
PSL/FRL also allows you to take any previously expression and do
global substitutions on subwords inside words or numbers inside
expressions(Thus allowing spelling corrections, and other word
changes easily.)
PSL/FRL is a set of read macros that insert the previous history
text asked for inplace of them selves. Thus they can be put inside
any lisp expression typed by the user. The system will evaluate
the resulting expression the same as if the user had retyped everything
in himself.
^^ : means insert last input command inplace of ^^.
As an input command by itself,
^^ by itself means redo last command.
^n : where n is a number replaces itself with the result of
(inp n). ^n by itself means (redo n).
^+n : same as ^n.
^-n : is replaced by the nth back command.
replaced with the result of
(inp (- current-history-number n)).
by itself means (redo (- current-history-number n))
^word : where word starts with 'a'-'z' or 'A'-'Z', means
take the last input command that has word as a subword
or pattern of what was typed (after readmacros were
executed.), and replace that ^word with that entire input
command.
If you want a word that doesn't begin with 'a'-'z', or 'A'-'Z',
use ^?word where word can be any lisp atom.
(say 23, *, |"ab|, word).
ex.: 1 lisp> (plus 2 3)
5
2 lisp> (* 4 5)
20
3 lisp> ^us
(PLUS 2 3)
5
4 lisp> (* 3 ^lu)
(PLUS 2 3)
15
Case is ignored in word. Word is read by the command read,
And thus should be a normal lisp atom. Use the escape
character as needed.
If the first ^ in any of the above commands is replaced with
^@, then instead of (inp n) , the read macro is replaced with
(ans n). Words are still matched against the input, not the
answer. (Probably something should be added to allow matching
of subwords against the answer also.)
Thus:(if typed as commands by themselves):
^@^ = (eval (ans (last-command)))
^@3 = (eval (ans 3))
^@plus = (eval (ans (last-command which has plus as a subword in
its input))).
Once the ^ readmacro is replaced with its history expression, you are
allowed to do some editing of the command. The way to do this
is to type a colon immediately after the ^ command as described
above before any space or other delimiting character.
ex.: ^plus:p
^2:s/ab/cd/
^^:p
^@^:p
Currently there are two types of editing commands allowed.
:p means print only, do not insert in expression, whole
read macro returns only nil.
:s/word1/word2/ means take each atom in the expression found,
and if word1 is a subword of that atom, replace the
subword word1 with word2. Read is used to read word1
and word2, thus the system expects an atom and will
ignore anything after what read sees before the /.
Use escape characters as necessary.
:n where n is a positive unsigned number, means take the nth
element of the command(must be a list) and return it.
^string1^string2^ is equivalent to :s/string1/string2/.
ex.: ^plus^plus^times^ is equivalent to ^plus:s/plus/times/ .
After a :s, ^ or :<n> command you may have another :s command, ^
or a :p
command. :p command may not be followed by any other command.
The expression as modified by the :s commands is what is
returned in place of the ^ readmacro.
You need a closing / as seen in the :s command above.
After the command you should type a delimiting character if
you wish the next expression to begin with a :, since a :
will be interpreted as another editing command.
On substitution, case is ignored when matching the subword,
and the replacement subword
is capitalized(unless you use an escape character before
typing a lowercase letter).
Examples:
1 lisp> (plus 23 34)
57
2 lisp> ^^:s/plus/times/
(TIMES 23 34)
782
3 lisp> ^plus:s/3/5/
(PLUS 25 54)
79
4 lisp>