From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69952 invoked by alias); 20 May 2017 20:09:26 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 69714 invoked by uid 89); 20 May 2017 20:09:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=disappointed, H*Ad:U*per X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 May 2017 20:09:23 +0000 Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dCAgl-0001DJ-Fp; Sat, 20 May 2017 22:09:23 +0200 Received: from 64-118-118-90-rt-broadband-00.broadband.oakhurst.sti.net ([64.118.118.90] helo=localhost.localdomain) by mailfront12.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1dCAgg-0006en-FW; Sat, 20 May 2017 22:09:18 +0200 Subject: Re: list comprehension patterns To: Helmut Eller , kawa@sourceware.org References: From: Per Bothner Message-ID: <040b274e-8320-0b67-4d96-cf93a8df97f9@bothner.com> Date: Sat, 20 May 2017 20:09:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-q2/txt/msg00072.txt.bz2 On 05/19/2017 08:38 AM, Helmut Eller wrote: > It would be nice to have some analog to Python's set and dictionary > comprehension not just list comprehensions. While Kawa has an OK hashtable API, I would like a more concise "map literal" syntax, plus I'd like to be able to use a map as a function (i.e. using funation call syntax, like Kawa allows for sequences). Not sure how to do dictionary/map comprehensions but definitely worth thinking about. I'm not convinced that set comprehensions are useful enough to be a priority. > Maybe also a concise syntax > way for things like "argmax". Hm. No brilliant ideas come to mind. You could do something like: (! mx (max @lst)) (! argmaxes ;; all max indexes (let (([i ...] [0 <: (length lst)])) [(if (= (lst i) mx) i) ...])) (! argmax (argmaxes 0)) ;; first max index That is obviously pretty klunky. > In general, I'm disappointed that Kawa moves away from prefix notation > (i.e. I will not use it these things). If you're referring to the postfix '...' operator, that is a little non-Scheme-y - but it is taken directly from R5RS syntax-rules. -- --Per Bothner per@bothner.com http://per.bothner.com/