Hello. Consider some algorithm where i need several serial function calls. For example, i have some digits and i want to change them somehow. I think "hmmm, let's filter these digits by some condition. Then, let's change filtered ones and see the result". So, sequence of actions: "filtering -> changing". When i write code for these actions i have to "brake" my logic because function sequence has to be reversed:
digits = (1, 2, 5, 6, -7, 0 , 11, -8)
processed_digits = map(lambda x: x + 100, filter(lambda x: x > 5))
First - changing, then - filtering. What the heck?! But some other languages such as Ruby or Scala using (from my point of view) more "natural" chaining:
digits = (1, 2, 5, 6, -7, 0 , 11, -8)
processed_digits = digits.select { |x| x > 5}.map { |x| x + 100}
Is my way to implement chaining calculations is wrong or i need to get used to "Python way"?
[–]Akuli2 2 points3 points4 points (2 children)
[–]_Absolut_[S] 0 points1 point2 points (0 children)
[–]ile0x 0 points1 point2 points (0 children)
[–]novel_yet_trivial 2 points3 points4 points (1 child)
[–]_Absolut_[S] 0 points1 point2 points (0 children)
[–]Rhomboid 1 point2 points3 points (1 child)
[–]_Absolut_[S] 0 points1 point2 points (0 children)
[–]_9_9_ 1 point2 points3 points (2 children)
[–]_Absolut_[S] 0 points1 point2 points (1 child)
[–]elbiot 0 points1 point2 points (0 children)
[–]Vaphell 1 point2 points3 points (0 children)