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


Groups > comp.lang.forth > #52982

Re: :Re: My LOOP is ugly

From Melzzzzz <mel@zzzzz.com>
Newsgroups comp.lang.forth
Subject Re: :Re: My LOOP is ugly
Date 2016-11-30 08:59 +0100
Organization albasani.net
Message-ID <20161130085951.15a09a6b@maxa-pc> (permalink)
References <o1h2gm$qse$1@gioia.aioe.org> <20161130063555.3d621465@maxa-pc> <87eg1t77b5.fsf@nightsong.com>

Show all headers | 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