Hannah Schroeter wrote:
>
> Hello!
>
> On Fri, Jun 04, 1999 at 12:18:31PM +0200, Friedrich Dominicus wrote:
>
> > [...]
>
> > > splitFilterMap unSplitFn afterMap filterPredicate beforeMap splitFn =
> > > unSplitFn . map afterMap . filter filterPredicate . map beforeMap . splitFn
> > [...]
>
> > sorry this looks morre terrible to me than all solutions before, IMO way
> > to much parameters and the names don't give me a good hint of what e.g
> > beforeMap does.
>
> That's a HOF
What's a HOF?
> that first splits something up to a list using splitFn
> (or with the generalization I mentioned, to a monad), then maps a
> function over that list (namely beforeMap, because it's mapped
> *before* the filter), filters something out (using the filterPredicate),
> then again maps a function (namely afterMap, because it's mapped
> *after* the filter), then somehow joins the list (or monad), using
> unSplitFn.
I would like names which tell me what is done.
I read in contents of a file
I process it, I build a string ...
etc
> > > lenGt limit list = length list > limit
>
> That's used as filter predicate.
I think I got that.
>
> > > number2str (nr,l) = show nr ++ '\t' : l
> > I would not call it number2 s.th it does not expplain to me that
> > something is printed so maybe
> > print_number_str_pair or the like would be fine for me
>
> But the function doesn't print either. It converts to a string.
> Therefore 2str. You could call it
> numberStrPair2String
> more accurately.
why not build_number_string_pair?
Sorry I havn't the Signature of Show in my mind bu of course it just
builds a string.
>
> > > processFile limit = splitFilterMap unlines number2str (lenGt limit . snd)
> > > id (numberElems . lines)
>
>
> Did you use the more functional parts of Python there? map? filter? :-)
No, just assignments loops and tuples ;-)
Regards
Friedrich