unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Function returning a list
@ 2020-12-19  0:34 steve-humphreys
  2020-12-19  9:04 ` tomas
  0 siblings, 1 reply; 3+ messages in thread
From: steve-humphreys @ 2020-12-19  0:34 UTC (permalink / raw)
  To: Help Gnu Emacs


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.

(defun timgrid-half (ta tb tpab tc td tpcd)
   (timgrid (ta tb tpab)) )

(setq tgl (typh-timgrid-half 800 1100 34 1300 1600 21))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Function returning a list
  2020-12-19  0:34 Function returning a list steve-humphreys
@ 2020-12-19  9:04 ` tomas
  2020-12-19  9:39   ` steve-humphreys
  0 siblings, 1 reply; 3+ messages in thread
From: tomas @ 2020-12-19  9:04 UTC (permalink / raw)
  To: help-gnu-emacs

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Function returning a list
  2020-12-19  9:04 ` tomas
@ 2020-12-19  9:39   ` steve-humphreys
  0 siblings, 0 replies; 3+ messages in thread
From: steve-humphreys @ 2020-12-19  9:39 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs


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
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-19  9:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-19  0:34 Function returning a list steve-humphreys
2020-12-19  9:04 ` tomas
2020-12-19  9:39   ` steve-humphreys

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).