From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Skip Montanaro Newsgroups: gmane.emacs.help Subject: Re: program to compute gears, with table Date: Fri, 8 Sep 2017 06:09:30 -0500 Message-ID: References: <86bmmlu54a.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1504869693 15203 195.159.176.226 (8 Sep 2017 11:21:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Sep 2017 11:21:33 +0000 (UTC) Cc: Help GNU Emacs To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 08 13:21:27 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqHL9-00023g-9y for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Sep 2017 13:20:51 +0200 Original-Received: from localhost ([::1]:44713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqHLG-0007oR-9g for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Sep 2017 07:20:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqHAI-0006eC-2R for help-gnu-emacs@gnu.org; Fri, 08 Sep 2017 07:09:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqHAC-0005ZO-Rl for help-gnu-emacs@gnu.org; Fri, 08 Sep 2017 07:09:38 -0400 Original-Received: from mail-it0-x22f.google.com ([2607:f8b0:4001:c0b::22f]:38248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqHAC-0005YA-L4 for help-gnu-emacs@gnu.org; Fri, 08 Sep 2017 07:09:32 -0400 Original-Received: by mail-it0-x22f.google.com with SMTP id c195so1208017itb.1 for ; Fri, 08 Sep 2017 04:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=J9XM6FA3qvflMkRaB2v8GYz/AZ+wi6ZSlCBYS5OhgPc=; b=bSLsExZc9fTVye80IgaDNDKIEOw7fHe8Nqo4n89ghAGPchyjmyhKtDyir/fFyADGJk R07J95tqhTMrji2kFEIChAAasShLWYm0r4XXPXZgtI2paxEF8kurLD72pVCt0jy8xDZl e6sv7tfcsfU6a2jDXMMtk3F0ay50+eZsWsBju2tcTdarkVh7gmNEqNA2paLeWgnZREca vCjJUPbI559Kheh74YyFJhy+cACkIJTOJoENL4JouPdolFgf73CdojG9+uuEuK4hfC0e Bdfi30AcDfZyqcoqEjtyXDOJLc3DvAcpoMV2XCKZopq91PoXd/Mmhdje3xCJZpwF82OQ fvjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=J9XM6FA3qvflMkRaB2v8GYz/AZ+wi6ZSlCBYS5OhgPc=; b=NBJ3W7aNOWEfAePCxK0Z/WbAnxnQCsNRK3YFfZaIEomgz+quhpePCD/MT37gibkOS6 blGDEDkUiS+g1OkuySS5rMhv6YGE4Z1CMLev4Ugpmf7dV2Xoa0pXqQs2m2cjdthHWadl 4dFaWXz17lfs5U+6mHkmwbQTF+8V3+V9D3IMNpQ4rXmWSeFuxCJ0/mgSC2COChEe5lEx 6MKBnTlPkOxfRZxhCAWdqPYDCJum84mxhEj3QBb46fs8gx2RbrVOHqmczkE7EixotarC EnJyMELvXgYAdacOxJntkMQEBJkuG0zgcGiEhjpKI5/ZyMj1iCksve8svYIO+IeHqlfB 1IyA== X-Gm-Message-State: AHPjjUgecSnGK9f8B+Pk8UkCMQ9BbcT2I2uBRLs8GXwTh2I2f9vhQxQc oMi7PAQHXNW8dqUAJayYtjkSQycyJ530Oj2HOErxtNg= X-Google-Smtp-Source: AOwi7QDF3hgtfezykVgJ3/t0rtjgxdgpuj1wvAZgiLJGICBmewEbmSPgeKQHsCNVE/HwugsNG+MZq/pl+0WTRQFswDY= X-Received: by 10.36.70.146 with SMTP id j140mr318047itb.83.1504868970599; Fri, 08 Sep 2017 04:09:30 -0700 (PDT) Original-Received: by 10.2.60.2 with HTTP; Fri, 8 Sep 2017 04:09:30 -0700 (PDT) In-Reply-To: <86bmmlu54a.fsf@zoho.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::22f X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114196 Archived-At: Something's fishy. Is the result mm of forward travel per crank revolution? I'm used to seeing gear inches. Your 50x12 should be about 110 gear inches. If your output is in millimeters, I get about 320 gear inches, so either I've mistaken your intended units, or there's a mistake in there somewhere. A couple nits which won't change anything: * Why the 1.0 divisor when computing gear? * You can skip the radius and use wheel (diameter) directly in computing the circumference. * It never occurred to me to do this in Lisp. I always just use an online calculator, like: http://www.gear-calculator.com/?GR=DERS&KB=34,50&RZ=12,13,15,17,19,21,23,25&UF=2150&TF=90&SL=2.6&UN=KMH Skip P.S. My latest acquisition (and oldest bike): https://www.flickr.com/photos/49705339@N00/albums/72157686279443084 On Fri, Sep 8, 2017 at 12:33 AM, Emanuel Berg wrote: > Hey guys, does this look right to you? > > ;; (print-gears '(34 50) '(12 13 15 17 19 21 23 25) 622) > ;; > ;; => > ;; > ;; 622 wheel > ;; > ;; chainring sprocket gear > ;; > ;; 34 25 2657.5360544880004 > ;; 34 23 2888.626146182609 > ;; 34 21 3163.7333982000005 > ;; 34 19 3496.7579664315795 > ;; 50 25 3908.1412566000004 > ;; 34 17 3908.1412566000004 > ;; 50 23 4247.97962673913 > ;; 34 15 4429.226757480001 > ;; 50 21 4652.549115000001 > ;; 34 13 5110.64625863077 > ;; 50 19 5142.291127105264 > ;; 34 12 5536.5334468500005 > ;; 50 17 5747.266553823531 > ;; 50 15 6513.568761 > ;; 50 13 7515.656262692309 > ;; 50 12 8141.960951250001 > > (require 'cl-lib) > > (defun compute-gear (chainring sprocket wheel) > (let*((pi 3.14159265) > (radius (/ wheel 2.0)) > (circum (* 2 radius pi)) > (gear (* (/ chainring sprocket 1.0) circum))) > (list chainring sprocket gear))) > > (defun gear (chainrings sprockets wheel) > (let*((gears > (cl-loop for c in chainrings > append (cl-loop for s in sprockets > collect (compute-gear c s wheel) ) > ))) > (cl-sort gears #'<= :key #'cl-caddr))) > > (defun print-gears (chainrings sprockets wheel) > (let ((out-buffer (get-buffer-create "*Gears*"))) > (with-current-buffer out-buffer > (erase-buffer) > (insert (format "%s wheel\n\n" wheel)) > (insert "chainring sprocket gear\n\n") > (let ((gears (gear chainrings sprockets wheel))) > (cl-loop for g in gears > do (let ((c ( car g)) > (s ( cadr g)) > (d (cl-caddr g))) > (insert (format " %s %s %s\n" c s > d)) )))) > (pop-to-buffer out-buffer) )) > > -- > underground experts united > http://user.it.uu.se/~embe8573 >