This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: list comprehension patterns
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/