Python Forum
Moving to Functional
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving to Functional
#11
@ndc85430 I know that numpy is not necessary to this task. Only numpy.sum() should be faster on numpy arrays than the above ersatz of sum of lists.

Thanks for the link to Toolz. I often use the more_itertools library already that helps managing iterables. I understand the advantages of less state and mutability and I like the idea of functional languages, but I have never used them for serious programs because they become very difficult to read as the program grows.

A nice thing in Python is the yield keyword. The above program could be written in a more human way by using 'yield' instead of 'itertools.chain'. It could help build a proper balance between imperative and functional programming in Python.
Reply
#12
Gribouillis - Tested and works - nice work! Now I just have to work on getting my head around it ;-)
Reply


Forum Jump:

User Panel Messages

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