From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: Printing a hash table Date: Mon, 23 Sep 2024 08:32:56 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eBNKtG0QGS1ru7Em" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="533"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 23 08:33:31 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sscdX-000ASH-6z for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 23 Sep 2024 08:33:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sscd5-00034O-NB; Mon, 23 Sep 2024 02:33:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sscd4-000342-2p for help-gnu-emacs@gnu.org; Mon, 23 Sep 2024 02:33:02 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sscd1-0006Xt-Lr for help-gnu-emacs@gnu.org; Mon, 23 Sep 2024 02:33:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+aRGaOl5Pl83KVHVk4xz6GzkBunq1jy7eX5DT+cCZmU=; b=YyjAOto7eno43yFyaXosCcPkVg pg8s6rVHKELpo8iFfslkJ6WgHnaHIgsHtlbi7B6DH7ZTmoRcXDW1wjNzPOT2kwwKmcvvNFMaKZU+c +/Bw95qfYuXA6UDfbSxWUdhWrLKGVE+nXcgjOc6SkYjRSUaGd81jwTkGtm9J5mS39y5CjbBqrKbXT BeVGtT/GoeqKlz9O15IqwRTbb9qMcOhZx9yVBci73dLzDGku2noun4AAoRvbtIehuX5AGjhPzq2qe h5CxLGaJAl+i9OEwlU115z2FEM+ct6AZtLKelAmrVTQjiRDb0ZggBg2P8BUVZBUdTY+8+SN6CXrbQ t4nxMGPA==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1ssccy-0006gX-Vq; Mon, 23 Sep 2024 08:32:57 +0200 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148041 Archived-At: --eBNKtG0QGS1ru7Em Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 23, 2024 at 02:30:31AM +0000, Heime wrote: > Is this the way to fill a hash table and print the values. =20 >=20 > (defvar marshal-fpln (make-hash-table :test 'equal) > "Hash table storing paths for different marshal components.") >=20 > (defun marshal-insert () >=20 > (puthash "MRSHL" marshal-waypt marshal-fpln) > (puthash "NAPLN" (concat marshal-waypt "/poleon") marshal-fpln) > (puthash "FLKTR" (concat rellana-waypt "/alkotr") marshal-fpln) > (puthash "GLXKS" (concat rellana-waypt "/xiakos") marshal-fpln) > (puthash "ARKTK" (concat rellana-waypt "/ritika") marshal-fpln) ) >=20 > (defun torium-hash-table (hash-table &optional bfrn) > "Print HASH-TABLE to the buffer BFRN." >=20 > (let* ( (bfname (or bfrn "Torium Hash Table")) > (dbuffer (get-buffer-create (concat "=F0=92=86=B3 " bfname))) ) >=20 > (with-current-buffer dbuffer > (maphash (lambda (key value) > (let* ( (start (point)) ) > (insert (format " =E2=94=81 %-8s" key)) > (insert (format "\n %s\n" value)))) > hash-table)))) >=20 > I am getting the following error and cannot figure out how I can get out = of it. >=20 >=20 > Debugger entered--Lisp error: (wrong-type-argument hash-table-p (("MRSHL"= ) ("NAPLN") ("FLKTR") ("GLXKS") ("ARKTK" . t))) > maphash((closure (t) (key value) (let* ((start (point))) (insert (forma= t " =E2=94=81 %-8s" key)) (add-text-properties start (point) '(face (:foreg= round "green"))) (insert (format "\n %s\n" value)))) (("MRSHL") ("NAPLN"= ) ("FLKTR") ("GLXKS") ("ARKTK" . t))) [rest of stack trace removed] Please, do some homework. This helps people help you (this is actually why I, at some point, stopped trying). Moreover, your (for the rest of us) inscrutable variable names aren't helping. Asking for programming help involves trying to help your helpers to understand your problem. I feel that you aren't doing this (for whatever reason). This will impair the quality of answers you get. And third, you really, really should try to gain some more understanding and practice with small Lisp code snippets. I have the impression that you only half-grasped very basic concepts and run into the same kind of problems time and again. Every bit you invest in the basics will pay back hundredfold (and will motivate your potential helpers). OK, that said, let's try to decode the two first lines of the error message (I reformat them to make them fit a civilised window width and to highlight their structure). Notes inline, prefixed with #. They are numbered to ref to them further down. > Debugger entered--Lisp error: # (1) The lisp run time has signalled an error, and the debugger is reporti= ng that: > (wrong-type-argument hash-table-p # (2) Some function expects an argument satisfying the predicate hash-table= -p and # has got instead... > (("MRSHL") ("NAPLN") ("FLKTR") ("GLXKS") ("ARKTK" . t))) # (3) ...something which looks a lot like an alist (the four first entries = are associated # to nil, that's why they possibly look like singletons) Ad (2): Which function could that be? Look again at your code. The only one I see is that maphash, restated (and abbreviated) here: > (maphash (lambda (key value) ...) hash-table) It gets two args (which corresponds to the doc). The first one is the function to be iterated. The second is hash-table, which, according to the doc, is expected to be a hash table. Now where is that one coming from? It is passed as a param to your torium-hash-table: we don't see how you are calling that one. I conclude that (unless I've missed something) the error cause is outside the code snippet you show us. Cheers --=20 t --eBNKtG0QGS1ru7Em Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZvELkgAKCRAFyCz1etHa RpuYAJ9SrWIhDpvLuslaSE5Oti3vrUBV1ACdEOVZHRPdSwUuLcwa/1ANr0UR+zo= =C0R8 -----END PGP SIGNATURE----- --eBNKtG0QGS1ru7Em--