Python Forum
Learning functional programming
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learning functional programming
#2
Functional programming isn't about using lambdas. It is about writing programs with functions where something goes in and something goes out, but nothing else happens. The functions don't change anything (no side-effects), they just return a value. From that perspective, your first function is as functional as your second. However, the first one is really better from a functional standpoint. One idea of functional programming is to make things easier to read by not making your guess what changes are happening when you call a function. I think your use of lambdas in the second program makes it harder to read, even though it's not introducing side-effects. Lambdas are inline, single-use functions. If you are giving them names so you can use them across multiple lines, you should really just define a function.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Learning functional programming - by vndywarhol - Aug-14-2018, 08:05 AM
RE: Learning functional programming - by ichabod801 - Aug-14-2018, 12:46 PM
RE: Learning functional programming - by micseydel - Aug-15-2018, 02:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  functional LEDs in an array or list? // RPi user Doczu 5 1,734 Aug-23-2022, 05:37 PM
Last Post: Yoriz
  Stuck in functional proggaming haze hammer 2 1,455 Oct-27-2021, 02:07 PM
Last Post: hammer
  OOP vs functional - - elaborate turn based RPG game (Derek Banas Udemy course again) Drone4four 6 4,069 Mar-14-2021, 08:38 AM
Last Post: ndc85430
  Calculating surface area - - OOP or functional? Derek Banas Udemy course Drone4four 5 3,719 Mar-13-2021, 06:22 AM
Last Post: buran

Forum Jump:

User Panel Messages

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