[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Elisp: Simple function to Add Two Numbers
From: |
Barry Margolin |
Subject: |
Re: Elisp: Simple function to Add Two Numbers |
Date: |
Sun, 27 Aug 2006 21:50:57 -0400 |
User-agent: |
MT-NewsWatcher/3.5.2 (PPC Mac OS X) |
In article <ihq64gdtz97.fsf@chlr7032.ch.intel.com>,
Edward Dodge <user@foo.bar> wrote:
> Pascal Bourguignon <pjb@informatimago.com> writes:
>
>
> > The whitespaces don't matter, as long as they're not just after a
> > newline. The problem is that there are two newlines with three
> > characters specifying a total of four interactive arguments: n, n and r.
> > (r gives two arguments, start and end of region).
>
> Yes, this is correct. And I have managed to keep the function from causing
> an error by rewriting it:
>
> (defun ekd-average (jabba wabba)
> "Adds two numbers and returns the difference between"
> (interactive "nFirstvar: \nnSecondvar: ")
> (eval ( + jabba wabba)))
You don't need eval.
>
> Now the only problem is this: it returns no answer when I run it. I thought
> lisp functions always returned a value. I even made it explicit by using the
> "eval" statement, but still I get no answer in either the minibuffer or
> *Messages*.
Yes, the function returns a value. But your command never displays the
value anywhere, and M-x doesn't automatically display the return value
of functions. Use (print (+ jabba wabba)) and it will be displayed in
the echo area.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Re: Elisp: Simple function to Add Two Numbers, David Kastrup, 2006/08/27