Python Forum
Moving to Functional
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving to Functional
#7
Here is my attempt in a non imperative style
import itertools as itt
import numpy as np
    
def count_incr(rec):
    return np.array(RecRan(rec, j) for j in range(10))
 
def ireport_group(date, irec):
    return itt.chain(
        (StrRec(rec) for rec in irec),
        (Summary(len(irec),
            list(np.sum(count_incr(rec) for rec in irec)), Strdate(date)),))

def Report():
    return ''.join(
        itt.chain.from_iterable(
            ireport_group(date, list(irec))
                for date, irec in itt.groupby(Load(), key=RecToDate)))
Reply


Messages In This Thread
Moving to Functional - by swisscheese - Dec-13-2020, 09:30 PM
RE: Moving to Functional - by Gribouillis - Dec-14-2020, 08:56 AM
RE: Moving to Functional - by swisscheese - Dec-14-2020, 01:41 PM
RE: Moving to Functional - by swisscheese - Dec-14-2020, 09:22 PM
RE: Moving to Functional - by Gribouillis - Dec-15-2020, 05:26 AM
RE: Moving to Functional - by swisscheese - Dec-15-2020, 10:27 AM
RE: Moving to Functional - by Gribouillis - Dec-15-2020, 05:45 PM
RE: Moving to Functional - by swisscheese - Dec-15-2020, 08:08 PM
RE: Moving to Functional - by Gribouillis - Dec-15-2020, 08:42 PM
RE: Moving to Functional - by ndc85430 - Dec-16-2020, 07:09 AM
RE: Moving to Functional - by Gribouillis - Dec-16-2020, 07:52 AM
RE: Moving to Functional - by swisscheese - Dec-17-2020, 12:57 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020