From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: beginnerquestion (nconc) Date: Wed, 22 Mar 2017 12:00:45 -0700 Message-ID: References: <87shmc1m2u.fsf@mail.de> <87k27nzvo7.fsf@mail.de> <87shm6d0r7.fsf@mail.de> <87mvcef8x1.fsf@jupiter.lan> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1490209433 2772 195.159.176.226 (22 Mar 2017 19:03:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 22 Mar 2017 19:03:53 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 22 20:03:48 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 1cqlXr-0008OK-4V for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Mar 2017 20:03:43 +0100 Original-Received: from localhost ([::1]:52922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqlXx-0002OU-0l for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Mar 2017 15:03:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqlVN-0000uY-4f for help-gnu-emacs@gnu.org; Wed, 22 Mar 2017 15:01:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cqlVL-0000Jb-Vx for help-gnu-emacs@gnu.org; Wed, 22 Mar 2017 15:01:09 -0400 Original-Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]:34057) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cqlVL-0000JP-RG for help-gnu-emacs@gnu.org; Wed, 22 Mar 2017 15:01:07 -0400 Original-Received: by mail-qt0-x22d.google.com with SMTP id n21so159504885qta.1 for ; Wed, 22 Mar 2017 12:01:07 -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; bh=46zaAM49yhBuKuiHPmHZet885XgQKOp2dlXoqWoL54g=; b=MQsRC6v7ov9Y2U6qHPU2Kv16N7lTxn5yqIbp2+yxZPhAyMWLNv6OaD3FQusBvECawB i56mMu/M1c5TIhCU1KB9Ik/lo/FSHuS5oOTntLlAUIQEf/YDQ4KV6G/8Jm3tSeRpv0Pc COWpysk+EM9WYaFDiPppgH7eCXu59kd0BwPTsoeaA2qZ56hYcK+cgaAy82rfGwfUwsX2 jOfIzAhJwdJJvfjstaR+pp7OB0CnStBArseUuCIyFu1LwZofW08aXvz1qxE0wV18rVri Lkncy/WMMuNBgx1SOhFIDbJKNp0aoj/nSNWw1OYKZifmp+9ty/91a88tbb6ooJOsjK+E XcyA== 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; bh=46zaAM49yhBuKuiHPmHZet885XgQKOp2dlXoqWoL54g=; b=npfhCE9JqEM4p1lhGcGLJdNZlVUB1G3dqyR3Hna0fRcIU9bzJC9wZbAR4vpO4NIwep THEet6Ez68tTLqN5CxhQuTv0gpBQdRbzr/ZcWg7A/w7T647jCrol0+8eHldWlyHtzHbA AYrBOLpHQjIx7OfbmJ7x7iAjv5ZHzLv08YN6yPDNFg/ai8pjnUVDTEi4scQDo7zXUxdD cXKLWOrlYVE1R43UDtY3N7TvW7jAIbGxC7yCHRX+nYCANkVzuWupzwrpnb9TZR3lXhdG PTer2LCsdfEPsgnvWUPr2cbvnuDQRsUqBmGfGJbstBJDYSuAHMnZNDWN3uf8kj7zf7Xm LzfA== X-Gm-Message-State: AFeK/H0NiaJVQO18xN9SqmZzDrGz1ZETVzX6eXk/8kmTjx5jDJLZR1X4aIiC0Cng5lsDh3yNsNmLeXjaNQUkOQ== X-Received: by 10.200.48.174 with SMTP id v43mr39359003qta.263.1490209266614; Wed, 22 Mar 2017 12:01:06 -0700 (PDT) Original-Received: by 10.237.49.162 with HTTP; Wed, 22 Mar 2017 12:00:45 -0700 (PDT) In-Reply-To: <87mvcef8x1.fsf@jupiter.lan> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::22d 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:112632 Archived-At: Stefan Huchler wrote: > I would even think about seq-position to get the id but that seems to be > not in 24.x version of seq.el >From an efficiency standpoint, that also means scanning the list over and over. It would only "really" matter if the list got largish, but it's easy enough to avoid. Another option would be to use something like `-map-indexed' from the `dash' library. (Incidentally, the efficiency concern also applies to using `dotimes' plus `elt' to iterate over a linked list). > your solution looks interesting, too. first you also use at least 1 > cl-... function I dont know what I have to thinb about that. isnt clisp > supposed to be ugly or bad? still everwhere you get suggestions about > it. People have a few different concerns with `cl' and `cl-lib': 1. `cl' introduces lots of non-namespaced names 2. Some people find the "cl"-prefixed names in `cl-lib' to be aesthetically unappealing 3. Some people find the programming style associated with Common Lisp to be aesthetically unappealing I avoid `cl' for the first reason above but the second and third don't trouble me much. > often the non (cl-) prefixed stuff seem to be wrappers or renamed > commonlisp functions, too? Yes, the idea of both `cl' and `cl-lib' is to provide Common Lisp-like functions that aren't present in Emacs Lisp's standard library. > also you used one time let and one time let* only a mistake or has that > any meaning? > > I thought let* is for most cases better? There is a reasonable argument to always use `let*', but my personal habit is to use `let' by default and only use `let*' when the difference between them is significant. > Wow and you use let after setq I never thought about that, but of course > it should/will work. Yes, either way works. > I am much about learning by doing, and to learn on concrete use cases / > needs. seems to kind of work. Meanwhile people (most important me) can > use the badly programmed but good usable kodi-remote if they want :) That's a good way to learn - it's hard to beat practice and experience. > yes I also used much python in the past. Well its more a emacs-lisp > specific thing right? I mean common-lisp has append. its not good for > performance critical stuff and huge amounts of data... which would be > pretty irrelevant for my usecase. The `push' / `nreverse' idiom is found in both Common Lisp and Scheme, and probably other Lisps too, though I don't have experience with most of the others. Common Lisp, Scheme, and Emacs Lisp all have `append', but it's not the same as Python's `list.append', because the underlying data structure is different. Lists in CL/Scheme/Elisp are singly-linked lists built from cons cells, which means it's inherently inefficient to append to the end. That's the ultimate reason for the `push' / `nreverse' style: you append at the front (where it's efficient to do so, but results in the elements being in reverse order), then reverse the list to get it back in the desired order. > But ok, if it leads me to better coding style, so be it. > > I did not use map and lambda very much in the past. But should start > doing that more :) Like any style or approach, it has its limits, but I think it's quite nice for many common uses. John