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

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

Re: Function returning a list


From: tomas
Subject: Re: Function returning a list
Date: Sat, 19 Dec 2020 10:04:58 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

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: signature.asc
Description: Digital signature


reply via email to

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