From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lewis Creary via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Program problem Date: Wed, 29 Nov 2023 00:16:46 +0000 (UTC) Message-ID: <446414867.4957940.1701217006858@mail.yahoo.com> References: <446414867.4957940.1701217006858.ref@mail.yahoo.com> Reply-To: Lewis Creary Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19678"; mail-complaints-to="usenet@ciao.gmane.io" To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 29 02:57:54 2023 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 1r89pp-00051x-UW for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 29 Nov 2023 02:57:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r89p6-0005Pr-AH; Tue, 28 Nov 2023 20:57:09 -0500 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 1r88HJ-0004xE-4U for help-gnu-emacs@gnu.org; Tue, 28 Nov 2023 19:18:09 -0500 Original-Received: from sonic304-10.consmr.mail.bf2.yahoo.com ([74.6.128.33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r88HG-0004pT-OY for help-gnu-emacs@gnu.org; Tue, 28 Nov 2023 19:18:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.com; s=a2048; t=1701217082; bh=+r/Pr6K9+cgsyTSV3NI3/SvW4DKvz16VS89W66m+e6I=; h=Date:From:To:Subject:References:From:Subject:Reply-To; b=iwDpVV1IHTDWUMbRLP0LGHfZ9ZmbLC6PJpnMqMLon4LrMpnwxoQKMAsfKrj9CBpSt/X4ARlUJ66ln4myN/VRpSt9vrr+oC3vfvCuOSKycSgrrqmhGyoQ0wOvX+z7oc8aN5wcBMgU6X6LV/K7xQl4Gk8UfamwxcoGuJxzqv0mDJ7BLkGxa70GYR1SLVcaI+GlyIMPvuvcJhLYTcmh9Q+I5RJiVB6ttcAkPOI7NtZw7qQ3KjuclMTXvbC9/j5BmnTAfo1l+sVoTFLUxCy3vk/0qdH11+A0XxAvDnraZ6C3kIJdIhCUiNHJPCnI7XnQnum2xdf5bB9F0DQNoDqlq79wzg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1701217082; bh=FfswY6i1boSTBXL7VhtUwb8moWdJCVnK4konfcVQgUL=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=oAwnTI+OQ1DWcQG6yH9du1v/R43dxZV9cbcun1xVYUFyhx8Se7LVH5wEIAm8Ni0qr8rftGNc5/6rpOKuar9BDkIdNLNfIBU3IgIM1V50d/C0mFhQsZXnEhtDlLhZpDN2ipzRiDoiVzmtZSeVRl210y6jsZGiOdDUtELbf3OmbwhR35G13HbfzRafge/qB9UcTadrAucxAOT7aK3Vo28R3lrJdN5jkhYuh9BFbqPgkTYExDt5gVyO5ZCtOYi5YNLZYBlRhL87NklrgZP4gpBLyhkz9DcLbo5r3P6Wn70KfnJZHtu55DDU6X7U0VYhSz9c4RhxIRzK0fLJ8M3+legI5A== X-YMail-OSG: w7dtpDMVM1mweOgpTkBpvuIJTa8sMpUTMI5QDKyr0GFx4XCC0zqfczqzKU.6wHu vXZDDeTtyttSAP_Qdw6VFKFKkjLbTD0axmzVGcj9Lje.dEbaGNxllM1_CJTllFW1g7h9mGzzWete gM67xQ9aW06Pr05aagRnWkFZdJN9PqfJF1L.xE.oB0DfhDv_FmInyDRd4Zdc0j3.UxJfzZ1493w. NFxrx24f3w20D48AP9qTgJAAgxEOA4glE4qj53I9lnQSzMc30_7hSr62ptruAG3qpoD1X5sdhXl3 EEFT5rrifJtATZetgZE2ETZmEE2XyV2.re._bxbbbyc5rI9frISHxcRS0cRkK7xXaD1bWCm31_Vx YXoe0xM4Bd8WkN23dhDszaEyzRNjNseacv3he35H6aXMziSvIV2PycaFPHbSbbOyY6eCWA_3mYJU WQwt1Xf.vJKZsAStDmYOWhegKqsK0eWU8UtG_9sQIHeLf2FBDmBb0WFuAPRYdTjJe2MqMlltbDKn TUFcg5UsMFORKilwfmmPhGqLdGCI9SQ.X65ntbsJlu1ruA5FZdpTJr1ttx3zl3Osna518iQYogq5 EanAwvw.0sFNmdBCgsRkFX4.jlRgH4pwm3pI6zKo3e8Bqxhnl_04KEuL9bKtt0Lnn5nOIp0t4szd 5lM5kBbe9PAjyZ94Ktr1hMKHEMgZ5S3zBJ7MGAuBEhsvZSOavTQK7yYLNqepquXFXQf1PfqmvIru rXumZde3.tz1qR319JYN3kCA8voX63UtHcWvtNpM.oYlxgMqH_CbP0QDZO_4o2jwyqwGLkswF4b4 x1igv02hWTXzBsoSF56ups0GbeEMzCQv6hoThH8jxr X-Sonic-MF: X-Sonic-ID: 5f24f65b-cce6-48b2-97ba-7b707ecf09b1 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Wed, 29 Nov 2023 00:18:02 +0000 X-Mailer: WebService/1.1.21896 AolMailNorrin Received-SPF: pass client-ip=74.6.128.33; envelope-from=lewcreary@cs.com; helo=sonic304-10.consmr.mail.bf2.yahoo.com 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 28 Nov 2023 20:57:01 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:145580 Archived-At: (It has been suggested to me by someone on the above mailing list thatthe f= ollowing content would be appropriate for this list.) My purpose here is to discuss a bug I've discovered in an emacs lispfunctio= n, fill-rows, that I've written (shown below).=C2=A0 The main ideaof this f= unction is to help solvers of Sudoku puzzles who want to keeptrack of the n= umbers they've already entered into a puzzle.=C2=A0 This willhelp them to b= acktrack when they change some of those numbers.=C2=A0 It'simportant to und= erstand the documentation string of this function(included in the function = definition) before reading the code. The use case of interest involves this function call:=C2=A0 =C2=A0(fill-row= s '(1 3 5)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '(= "123456789" "987654321" "123498765") =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 '((0 0 0 0 0 0 0 0 0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A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0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2= =A0(0 0 0 0 0 0 0 0 0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0=C2=A0(0 0 0 0 0 0 0 0 0)) Here, then, is the function definition: (defun fill-rows (row-nums change-strings pzl-form)=C2=A0 "This fn takes as= arguments a list of row indices, a list of an equal=C2=A0 =C2=A0number, s,= of 9-digit strings, and a puzzle form (i.e, an sexp of the form:=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((n n n n n n n n n)= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(n n n= n n n n n n)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0(n n n n n n n n n)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(n n n n n n n n n)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(n n n n n n n n n)=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(n n n n n n n n n)=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(n n n n n n = n n n)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (n n n n n n n n n)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(n n n n n n n n n)), where n is a number between 0 and 9).=C2= =A0 =C2=A0The fn returns as value t he result of filling in row m of the ar= gument=C2=A0 =C2=A0puzzle form with numbers specified by the mth 9-digit st= ring."=C2=A0 (let* ((row-index 0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= row-num-index 0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(row-str (nth row-= index change-strings))=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(row-num (nt= h row-num-index row-nums))=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(change-= nums nil)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(str-pos 0) )=C2=A0 =C2= =A0 =C2=A0 (while (and (< row-index (length row-nums)) (< str-pos 9))=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; (comment) cycle through the ch= ange-strings=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (while (< str-pos 9) =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; cycle through row-str, = contributing to change-list=C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (setq change-nums (append change-nums =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (list (string-to-number =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(substring row-str str-pos (1+ str-pos)) )) )=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 row-str (nth ro= w-index change-strings) )=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (= setcar (car (nthcdr row-num pzl-form))=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (nth str-pos change= -nums) )=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cl-incf str-pos) )=C2=A0 =C2=A0= =C2=A0 =C2=A0(cl-incf row-index)=C2=A0 =C2=A0 =C2=A0 =C2=A0(cl-incf row-nu= m-index) )=C2=A0 =C2=A0pzl-form ) ) ---------------------------------------------------------------------------= ------------------------- I'll very much appreciate receiving any proposed bugfixes or other=C2=A0 su= ggestions you may have. Thanks. Lewis Creary