help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs New User Questions


From: Pascal J. Bourguignon
Subject: Re: Emacs New User Questions
Date: Tue, 26 May 2009 14:49:33 +0200
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (gnu/linux)

Ben Badgley <address@hidden> writes:

> I've been looking over "Practical Common Lisp" and of course "An
> Introduction to Programming in Emacs Lisp", along with "On Lisp".
> Have read more in the past week than probably the past two years.
> Also found Cliki and started delving into it. Been reading the Lisp
> newsgroup a bit too.
>
> Recently there was what seemed a major flame war over Lisp
> vs. Java. I'll keep out of those sorts of things. Everyone has a
> rectum and opinion. No point in showing how much both stink. And again
> thank you
> for the excellent pointers, and reminding ever so gently to rtfm and
> source. :)
>
> One of my goals at this point is to use Emacs as an environment to
> write short stories, novels. Learning to program will be an outlet
> hobby for me, as well as provide more practical means to attain the
> goals. Who knows? I might even be good enough at one, or the other to
> make a modest wage.


And you may even use Lisp to write story writing code :-)

(defun choose-from (items) (nth (random (length items)) items))
(defun noun  () (choose-from '(jack jane joe)))
(defun verb  () (choose-from '(eats paints drops)))
(defun thing () (choose-from '(the\ apple the\ wall the\ dog)))

#+common-lisp
(defun story () (loop :repeat (1+ (random 5)) 
                      :do (format t "~:(~A~) ~(~A ~A~).~%" (noun) (verb) 
(thing))))

#+emacs
(require 'cl)
#+emacs
(defun story () (loop repeat (1+ (random 5)) 
                      do (insert (format "%s %s %s.\n" (noun) (verb) (thing)))))

(story)
jane drops the dog.
jack paints the apple.
jane drops the apple.
nil

Of course, with time you may develop some kind of AI or at least
expert system to design more interesting stories and better literary
style...

-- 
__Pascal Bourguignon__


reply via email to

[Prev in Thread] Current Thread [Next in Thread]