From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Function returning a list
Date: Sat, 19 Dec 2020 10:04:58 +0100 [thread overview]
Message-ID: <20201219090458.GB20010@tuxteam.de> (raw)
In-Reply-To: <trinity-a1a88a04-ece9-486f-9f37-ffa07bdbd452-1608338084987@3c-app-mailcom-bs02>
[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]
On Sat, Dec 19, 2020 at 01:34:45AM +0100, steve-humphreys@gmx.com wrote:
>
> I have a function "timgrid" that returns a list. But the list returned
> by "timgrid-half" got problem in the values. The output for "tgl" is
> also problematic.
Steve,
if you want to give us half a chance to help out, you should try to
be a bit more specific.
What does it mean that a list "got problem in the values"? Surely
the list doesn't mind. Perhaps you don't like the values in the
list. But then, we'd like to know:
- what values are there
- what values you expect to be there
- how those values were produced, and (ideally)
- your mental model of the above process.
Now let me label those two code snippets:
[A]
> (defun timgrid-half (ta tb tpab tc td tpcd)
> (timgrid (ta tb tpab)) )
[B]
> (setq tgl (typh-timgrid-half 800 1100 34 1300 1600 21))
I don't know what they are trying to do -- but there is at least
one error. In [A], second line, you say:
[A1] (timgrid (ta tb tpab))
which in Lisp means:
[A1.1] (ta tb tpab) == apply function `ta' to the args `tp' and
`tpab'
[A1.2] (timgrid ...) == apply function `timgrid' to the above
result
BUT... according to [B], you pass the value 800 for ta in the
call. Now 800 is not a function (at least not in our little world
of Elisp). So Emacs complains with something like:
Debugger entered--Lisp error: (invalid-function 800)
(800 1100 34)
(progn (800 1100 34))
eval((progn (800 1100 34)) t)
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)
... and it is right: 800 ain't a function.
(Hint: if you see such an error message, fight the first reaction.
Don't panic. Elisp is trying to tell you something. Try to understand
it. Copy snippets of it to include them next time you ask for help.
Next error will be easier).
I have a hunch that you got confused with the traditional math notation
"f(x)" to apply function f to arg(list) x and Lisp notation (f x) for
(eh -- roughly) the same.
But you keep so tight-lipped about whatever is happening behind your
Internet socket that I can only guess :-)
HTH
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2020-12-19 9:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-19 0:34 Function returning a list steve-humphreys
2020-12-19 9:04 ` tomas [this message]
2020-12-19 9:39 ` steve-humphreys
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201219090458.GB20010@tuxteam.de \
--to=tomas@tuxteam.de \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).