From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: soyeomul@doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Newsgroups: gmane.emacs.devel Subject: Re: verify ISSN (issn-verify.el) Date: Fri, 11 Sep 2020 13:58:03 +0900 Organization: =?utf-8?B?6YeR6Zm1ICjsl7Dsm5DsnZgg66eI7J2MKQ==?= Message-ID: References: <87r1r96len.fsf@ebih.ebihd> 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="37595"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 11 06:58:49 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kGb96-0009fF-T0 for ged-emacs-devel@m.gmane-mx.org; Fri, 11 Sep 2020 06:58:48 +0200 Original-Received: from localhost ([::1]:43820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGb95-0001pq-VU for ged-emacs-devel@m.gmane-mx.org; Fri, 11 Sep 2020 00:58:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGb8b-0001QA-3D for emacs-devel@gnu.org; Fri, 11 Sep 2020 00:58:17 -0400 Original-Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:43115) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kGb8Z-0008Ac-DE for emacs-devel@gnu.org; Fri, 11 Sep 2020 00:58:16 -0400 Original-Received: by mail-pg1-x529.google.com with SMTP id t14so5737256pgl.10 for ; Thu, 10 Sep 2020 21:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=doraji.xyz; s=yw; h=from:to:subject:organization:message-id:references:date:in-reply-to :user-agent:mime-version:content-transfer-encoding; bh=u7C0voxAwaRlVfU/6P/G25D4AYeEEBt9PWmW/P1On04=; b=GkyGG6zbkZar3k2IFN20AwyTMHNtoexK9K0vp9Uro4N3PWmByceaYLgNnEp/AyEhvG LxDt3rubAAtp69euMRSX+mgCkp2qoEZ5UtlbMJ5XiFDOo6L8tlKkxyGjAXzX5BjkfAfs ipDThYV9IfJ3oQda4f0+OwekXuHAOwz+CMM0ffy+dHWWVQaDVAlTnDeJkC7rI06jn7cC xDwLFMTPonD5jD5uXzLyTL4Xbx54c8WR8SAfiP1bTlUrqovXKBKp9ZcfOA+EZ3sQ8o5X m4130k9EYFsbM1BtU9iwHbK9r8u/DPG/DpkGvrfi1hgF2S8zxKRtVs7NflNVHJDLxMtT 8P1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:message-id :references:date:in-reply-to:user-agent:mime-version :content-transfer-encoding; bh=u7C0voxAwaRlVfU/6P/G25D4AYeEEBt9PWmW/P1On04=; b=EX3xsP6dP5zZ4fH2J/7zxL8EjwxKktYmum0/7kSwW4tej3guEtrtQ9w4GTFq9xNay/ 7flQJ5ToUD2MX7fCV2KqWGm3JZBh7JHpOVxTgg4Cge2l33WolnKBSCG/+IopD86BqpK7 Un8Hlno5+SPVSVdBwG8p0GhCACzL37eumCxxZ85y/hl1Cvfp21GX9TIke8PmfMSsGWux 98gczOPdFrTMMlBg7mbSIw4CY3OIi5+vMtSb/gp/2LqDIMQ+8WoSyU/4leo7XruuO87Y nKhTGiENrrRJTR7qsvzk98WdxJnF9D4uMU3shh0kEkoqr0i3gPdv24hHD+hzYCky7iGZ cUJQ== X-Gm-Message-State: AOAM5315ygQF5hRLwnqR8VrV4hyfQ80tYEMbto30iI7PcP/xn4J/9XZV oITJTMARuAWFCnDYhzMhZzqKKKTCwFSesXxB X-Google-Smtp-Source: ABdhPJxbLSP5VJNzrmp4Q7AiEy3JNz8CKgx1JlpXVukGR/pjuZvt7Gpk1SEaOF4e+StC1akA8nswgw== X-Received: by 2002:a62:8c86:: with SMTP id m128mr563295pfd.111.1599800293050; Thu, 10 Sep 2020 21:58:13 -0700 (PDT) Original-Received: from delta.birch.chromebook ([203.226.208.207]) by smtp.gmail.com with ESMTPSA id i20sm568702pgk.77.2020.09.10.21.58.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Sep 2020 21:58:12 -0700 (PDT) Original-Received: by delta.birch.chromebook (sSMTP sendmail emulation); Fri, 11 Sep 2020 13:58:04 +0900 X-Thanks-Workers: =?utf-8?B?7J2066eI65GQLCDsnbTsiJzsi6AsIOyghOuqheyImSwg?= =?utf-8?B?7KeE7ZGc7Jyo7IKsLCDqtIDsmrTsnqUsIOqwle2DnOqztQ==?= X-Thanks-Today: =?utf-8?Q?https=3A=2F=2Fgitlab=2Ecom=2Fsoyeomul=2FGnus=2F-?= =?utf-8?Q?=2Fraw=2FMaGnus=2Fjk=2F=EA=B6=8C=EC=A7=802=EC=9E=A538=EC=A0=88?= =?utf-8?Q?=2Etxt?= X-Thanks-Thanks-Thanks: =?utf-8?B?7LKc7ZWY7LC97IOd7J2EIOuLpCDsgrTrpqzsi5w=?= =?utf-8?B?66Ck64qUIOuniOydjC4uLl5eXg==?= X-Thanks-MID-Tool: https://gitlab.com/soyeomul/__yw__/-/blob/master/tmid.py X-Thanks-Absolete-Coding-System: UTF-8 X-Operating-System: =?utf-8?B?4omqZGluZ+KJqw==?= -- The Gnus X-Gnus-Motto: In a cloud bones of steel. X-Gnus-Desktop: GNOME ('Ubuntu', '18.04', 'bionic') In-Reply-To: <87r1r96len.fsf@ebih.ebihd> (Emanuel Berg via's message of "Fri, 11 Sep 2020 05:29:36 +0200") Received-SPF: none client-ip=2607:f8b0:4864:20::529; envelope-from=soyeomul@doraji.xyz; helo=mail-pg1-x529.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 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, FROM_SUSPICIOUS_NTLD=0.499, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_PDS_OTHER_BAD_TLD=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:255091 Archived-At: Emanuel Berg via "Emacs development discussions." writes: > ;;; issn-verify.el --- verify ISSN -*- lexical-binding: t > ;; > ;;; Commentary: > ;; > ;; This Elisp package provides functions to verify > ;; ISSN by computing their check digits. > ;; > ;; Author: Emanuel Berg (incal) > ;; Created: 2020-09-06 > ;; Keywords: bib, tex > ;; License: GPL3+ > ;; Package-Requires: ((cl-lib "1.0")) > ;; URL: https://dataswamp.org/~incal/emacs-init/issn-verify.el > ;; Version: 1.0.0 > ;; > ;; Also see: > ;; > ;; https://dataswamp.org/~incal/emacs-init/isbn-verify.el > ;; > ;; To install this package, with this file in > ;; a buffer, do: > ;; > ;; M-x load-file RET RET > ;; > ;; International Standard Serial Number: > ;; > ;; ISO 3297, 1975 > ;; > ;; format: > ;; > ;; The Ring Magazine: ISSN 0035-5410 > ;; d_1d_2d_3d_4-d_5d_6d_7c > ;; d_i for i \in [1, 7] is an integer > ;; c, the check digit, is 0..9 or X for 10 > ;; > ;; compute check digit c: > ;; > ;; c' =3D 8d_1*7d_2*6d_3*5d_4*4d_5*3d_6*2d_7 mod 11 > ;; > ;; { 0 c' =3D 0 > ;; c =3D { > ;; { 11 - c' else > ;; > ;;; Code: > > (require 'cl-lib) > > (defun issn--get-digits (issn) > (when (string-match "[[:digit:]]\\{4\\}-[[:digit:]]\\{3\\}[X[:digit:]]"= issn) > (let*((hyphen-pos 4) > (issn-lst (string-to-list issn)) ) > (mapcar (lambda (c) (if (eq ?X c) "X" (- c ?0))) > (append (cl-subseq issn-lst 0 hyphen-pos) > (cl-subseq issn-lst (1+ hyphen-pos)) ))))) > > (defun issn-verify-issn (issn) > (let*((issn-lst (issn--get-digits issn)) > (c-prop (car (last issn-lst))) > (c-w 0) ) > (cl-loop for d in issn-lst > for w downfrom 8 to 2 > do (cl-incf c-w (* w d)) ) > (let*((c-prime (mod c-w 11)) > (c (cond ((=3D c-prime 0) 0) > (t (- 11 c-prime) ))) > (c-x (if (=3D 10 c) "X" c)) ) > (if (equal c-prop c-x) > (message "%s (OK)" c-x) > (message "NOT OK! is %s, should be %s" c-prop c-x) )))) > > ;; Bicycle Quarterly (issn-verify-issn "1941-8809") > ;; Bicycling (issn-verify-issn "1651-9744") > ;; Black Belt (issn-verify-issn "0277-3066") > ;; Filter (issn-verify-issn "1654-9813") > ;; Linux Pro (issn-verify-issn "1471-5678") > ;; National Geographic (issn-verify-issn "2535-4124") > ;; Outside (issn-verify-issn "0278-1433") > ;; The Ring (issn-verify-issn "0035-5410") > > ;; The Economist (issn-verify-issn "0013-0614") ; NOT OK! is 4, sho= uld be 3 > > (provide 'issn-verify) > ;;; issn-verify.el ends here Still i don't know emacs lisp but your codes looks beautiful, wow!!! Cheer up and thanks Emanuel^^^ Sincerely, Byung-Hee --=20 ^=EA=B3=A0=EB=A7=99=EC=8A=B5=EB=8B=88=EB=8B=A4 _=E5=92=8C=E5=90=88=E5=9C=98= =E7=B5=90_ =EA=B0=90=EC=82=AC=ED=95=A9=EB=8B=88=EB=8B=A4_^))//