Steve Howell <showel...@yahoo.com> writes:
>> http://haskell.org/ghc/docs/6.10.4/html/users_guide/syntax-extns.html...
>> might be of interest.  Maybe Ruby and/or Python could grow something similar.
> Can you elaborate?

List comprehensions are a Python feature you're probably familiar with,
and I think Ruby has something like them too.  They originally came from
Haskell.  GHC (the main Haskell implementation) now supports an extended
list comprehension syntax with SQL-like features.  I haven't used it
much yet, but here's an example from a poker ranking program
(http://www.rubyquiz.com/quiz24.html) that I did as a Haskell exercise:

  let (winners:others) = 
        [zip c ls | ls <- lines cs
                , let {h = mkHand ls; c=classify h}
                , then group by c
                , then sortWith by Down c]

It's reasonably evocative and doing the same thing with the older
syntax would have been a big mess.  "Down" basically means sort
in reverse order.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to