From: Alexander Schmolck
Subject: Re: Emacs Lisp print problem
Date: 
Message-ID: <yfsd5hmrqtg.fsf@oc.ex.ac.uk>
·····@stevedurkin.net writes:

> Here is the whole program if necessary:

You already got an answer to your specific question, some other remarks (if
this is just a one-of excercise, ignore what you think you don't need):

- don't put ) on empty lines. It's considered bad style and if you understand
  how to use emacs properly you don't need to pay visual attention to those
  parens. 

- always declare global variables with defvar and local ones with let

- 't is the same as t (the boolean true). I assume that instead of 'f you want
  nil (the boolean false and also the empty list). Then your accept function
  just becomes (defun accept (state)
     (equal (% state 2) 1)) ; (= (% state 2) 1) is more idiomatic

- for two-armed conditionals you could also use if

> (defun FA (str)
>  (cond
>   ((null str) state)
>   ((equal (car str) 97)

You can also write (equal (car str) ?a).

>    (cond
>      ((equal state 1) (setq state 3))
>      ((equal state 2) (setq state 4))
>      ((equal state 3) (setq state 4))
>      ((equal state 4) (setq state 5))
>      ((equal state 5) (setq state 2))
>    )

If you put a (require 'cl) at the top of your file, you could replace the cond
with:

 (setq state (ecase state (1 3) (2 4) (3 4) (4 5) (5 2)))

It's shorter, gives an error if state is not in 1..4 (if you don't want that
use case instead) and should also be more efficient (not that it matters
here).

Similarly you could then also use (incf i) instead of (setq i (+ i 1)).

'as
From: ·····@stevedurkin.net
Subject: Re: Emacs Lisp print problem
Date: 
Message-ID: <1140228594.244730.181130@f14g2000cwb.googlegroups.com>
thanks for all the info...it is a one-of exercise, but i still
appreciate all the information and advice.