public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Helmut Eller <eller.helmut@gmail.com>, kawa@sourceware.org
Subject: Re: list comprehension patterns
Date: Sat, 20 May 2017 20:09:00 -0000	[thread overview]
Message-ID: <040b274e-8320-0b67-4d96-cf93a8df97f9@bothner.com> (raw)
In-Reply-To: <m260gwq2kf.fsf@gmail.com>

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/

      reply	other threads:[~2017-05-20 20:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 17:00 Per Bothner
2017-05-17 23:31 ` Sudarshan S Chawathe
2017-05-20 20:56   ` Per Bothner
2017-05-18 22:58 ` Andrea Bernardini
2017-05-20 21:03   ` Per Bothner
2017-05-19 15:38 ` Helmut Eller
2017-05-20 20:09   ` Per Bothner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=040b274e-8320-0b67-4d96-cf93a8df97f9@bothner.com \
    --to=per@bothner.com \
    --cc=eller.helmut@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).