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: steve-humphreys
Subject: Re: Function returning a list
Date: Sat, 19 Dec 2020 10:39:39 +0100

I discovered that I was updating the next value in the list, but
storing it inside a let, so the list continued putting the same
value.

And yes, I made a mistake by calling it as math notation.  Must have
been an old flashback from korea.




> Sent: Saturday, December 19, 2020 at 2:34 PM
> From: tomas@tuxteam.de
> To: help-gnu-emacs@gnu.org
> Subject: Re: Function returning a list
>
> 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
>



reply via email to

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