all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: execute defun on reception of signal
Date: Tue, 14 Jul 2015 04:41:40 +0200	[thread overview]
Message-ID: <87bnffo3yz.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.6892.1436840915.904.help-gnu-emacs@gnu.org

Emanuel Berg <embe8573@student.uu.se> writes:

> Rusi <rustompmody@gmail.com> writes:
>
>> However on a docs-improving note here's this little
>> titbit: [On other thread] There was this claim
>> "letrec is nice" or some such. Since I know letrec
>> from scheme etc but never seen in elisp I was
>> curious. I find: describe-function tells nothing
>> about the recursion the elisp info pages (index)
>> seems to not have it at all
>
> There is no mention of "letrec" in
>
>     /usr/share/info/emacs-24/elisp.info
>
> I don't know the policy. Are *all* functions, macros,
> etc. supposed to be in the Elisp manual?

letrec is not emacs lisp, it's scheme.

In Common Lisp, one would use labels, so in emacs lisp you can write:

    (require 'cl)
    (defun fact (n)
      (labels ((f (n f)
                 (if (plusp n)
                     (f (- n 1) (* n f))
                     f)))
        (f n 1)))

provides a nice tail-recursive factorial implementation.

    (fact 10) --> 3628800
    (fact 41) --> 1716706262231547904


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


  parent reply	other threads:[~2015-07-14  2:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-12  1:59 execute defun on reception of signal Emanuel Berg
2015-07-12 10:27 ` Andy Moreton
2015-07-12 16:56   ` Emanuel Berg
2015-07-12 18:54     ` Andy Moreton
2015-07-13  3:53       ` Vaidheeswaran C
2015-07-14  1:49         ` Emanuel Berg
     [not found]     ` <mailman.6808.1436727285.904.help-gnu-emacs@gnu.org>
2015-07-13  2:29       ` Rusi
2015-07-13  2:57         ` Emanuel Berg
2015-07-13  3:39           ` Vaidheeswaran C
2015-07-14  1:43             ` Emanuel Berg
2015-07-14  1:58               ` Vaidheeswaran C
2015-07-14  1:59                 ` Emanuel Berg
2015-07-14  2:07                   ` Emanuel Berg
2015-07-14  2:09                   ` Vaidheeswaran C
2015-07-14 22:14                     ` Emanuel Berg
2015-07-13  8:28         ` Andy Moreton
2015-07-13 14:49           ` Nicolas Richard
2015-07-13 15:22             ` Eli Zaretskii
2015-07-13 14:44         ` Eli Zaretskii
     [not found]         ` <mailman.6850.1436798656.904.help-gnu-emacs@gnu.org>
2015-07-13 14:57           ` Rusi
2015-07-13 15:18             ` Thierry Volpiatto
2015-07-13 15:28             ` Eli Zaretskii
     [not found]             ` <mailman.6858.1436801328.904.help-gnu-emacs@gnu.org>
2015-07-13 16:13               ` Rusi
2015-07-14  1:53             ` Emanuel Berg
     [not found]             ` <mailman.6892.1436840915.904.help-gnu-emacs@gnu.org>
2015-07-14  2:41               ` Pascal J. Bourguignon [this message]
2015-07-14 21:33                 ` Emanuel Berg
     [not found]                 ` <mailman.6932.1436909731.904.help-gnu-emacs@gnu.org>
2015-07-14 22:11                   ` Pascal J. Bourguignon
2015-07-14 22:21                     ` Emanuel Berg
     [not found]                     ` <mailman.6936.1436912565.904.help-gnu-emacs@gnu.org>
2015-07-15 15:25                       ` Rusi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bnffo3yz.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.