Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #52982

Re: :Re: My LOOP is ugly

Path csiph.com!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From Melzzzzz <mel@zzzzz.com>
Newsgroups comp.lang.forth
Subject Re: :Re: My LOOP is ugly
Date Wed, 30 Nov 2016 08:59:51 +0100
Organization albasani.net
Lines 24
Message-ID <20161130085951.15a09a6b@maxa-pc> (permalink)
References <o1h2gm$qse$1@gioia.aioe.org> <20161130063555.3d621465@maxa-pc> <87eg1t77b5.fsf@nightsong.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net g4R1bawTnb9cy2kyb8F6H7fnIhqnDqexTyAwu7Pjb0qOqHsC746XfKOEGUuvnW2k/w5F5/WhFZwv+Mj3tNSsvQ==
NNTP-Posting-Date Wed, 30 Nov 2016 07:59:51 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="un2TE8QFSeAE3gLMz7iXDebIQt0TOogdn4+tJFAs4NoNmRnzTakdWrG8AEXdP/0cb0pPkSMlGQ20es7K/3iM7Jlbm1k84Nzl0GLnKjO9HPdRG3SnFMA3f7OHDIOa2Nem"; mail-complaints-to="abuse@albasani.net"
X-Newsreader Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
Cancel-Lock sha1:pyO9iof0T5v8jy2LWMpumORQXhg=
Xref csiph.com comp.lang.forth:52982

Show key headers only | View raw


On Tue, 29 Nov 2016 23:31:10 -0800
Paul Rubin <no.email@nospam.invalid> wrote:

> {-# LANGUAGE TransformListComp #-}
> import GHC.Exts (sortWith, groupWith, the)
> import Data.Char (toUpper)
> import Data.Function (on)
> 
> p2b xs = [ (the a, b) | (a,b) <- xs
>          , then sortWith by b
>          , then group by a using groupWith 
>          ]
> 
> t1 = [('C',3),('A',1),('B',2),('A',2),('C',2)]
> t2 = [("bar",44),("Foo",2),("foo",22),("BAR",4)]
> 
> main = do
>   print . p2b $ t1
>   print . p2b $ [(map toUpper a, b) | (a,b) <- t2]

Wow! Really nice!

-- 
press any key to continue or any other to quit

Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

:Re: My LOOP is ugly "Robert L." <No_spamming@noWhere_7073.org> - 2016-11-28 10:56 +0000
  Re: :Re: My LOOP is ugly trans <transfire@gmail.com> - 2016-11-28 06:37 -0800
  Re: :Re: My LOOP is ugly Melzzzzz <mel@zzzzz.com> - 2016-11-30 06:35 +0100
    Re: :Re: My LOOP is ugly Paul Rubin <no.email@nospam.invalid> - 2016-11-29 23:31 -0800
      Re: :Re: My LOOP is ugly Melzzzzz <mel@zzzzz.com> - 2016-11-30 08:59 +0100

csiph-web