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


Groups > comp.lang.forth > #24139

Re: Simple problem

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject Re: Simple problem
Date 2013-07-03 21:32 -0700
Organization Nightsong/Fort GNOX
Message-ID <7xr4ffx7uz.fsf@ruckus.brouhaha.com> (permalink)
References <kgs058018sm@enews4.newsguy.com> <kr2pt0$e2q$1@dont-email.me>

Show all headers | View raw


"WJ" <w_a_x_man@yahoo.com> writes:
> OCaml:
> let update_tbl tbl s =
>   if Hashtbl.mem tbl s then ...

That is horrendous, Java code written in Ocaml.  Haskell:

    import Data.Map(insertWith,empty,toList)
    counts = toList . foldr (\x->insertWith (+) x 1) empty

Output:

    > counts ["a","b","a","c","c","c"]
     ==> [("a",2),("b",1),("c",3)]

Alternatively:

    import Data.List(group,sort)
    import Control.Arrow((&&&))
    counts = map (head &&& length) . group . sort

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


Thread

Simple problem "WJ" <w_a_x_man@yahoo.com> - 2013-03-02 04:45 +0000
  Re: Simple problem Doug Hoffman <glidedog@gmail.com> - 2013-03-02 06:16 -0500
  Re: Simple problem "WJ" <w_a_x_man@yahoo.com> - 2013-03-18 05:41 +0000
    Re: Simple problem albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-03-18 11:23 +0000
    Re: Simple problem "WJ" <w_a_x_man@yahoo.com> - 2013-06-15 00:53 +0000
      Re: Simple problem visualforth@rocketmail.com - 2013-06-21 20:14 -0700
        Re: Simple problem glidedog@gmail.com - 2013-06-22 06:01 -0700
          Re: Simple problem rickman <gnuarm@gmail.com> - 2013-06-22 09:48 -0400
          Re: Simple problem Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-22 22:55 +0200
            Re: Simple problem "Elizabeth D. Rather" <erather@forth.com> - 2013-06-22 11:47 -1000
  Re: Simple problem "WJ" <w_a_x_man@yahoo.com> - 2013-04-02 08:22 +0000
  Re: Simple problem "WJ" <w_a_x_man@yahoo.com> - 2013-07-04 03:24 +0000
    Re: Simple problem Paul Rubin <no.email@nospam.invalid> - 2013-07-03 21:32 -0700
  Re: Simple problem "WJ" <w_a_x_man@yahoo.com> - 2013-07-04 10:03 +0000

csiph-web