I have studied several articles, some chapters of books about FP and I would like to practice it a lot to make FP paradigm as part of my mind. But I still can't get it and it's really easy to doubt myself.
preguntado el 08 de enero de 11 a las 16:01
To embrace functional programming, you must stop thinking of variables as memory locations whose values can be changed over and over again. Instead, think of your data as an immutable lump that is fed into a function, producing another immutable lump of data. If you have used UNIX (or DOS) tuberías, they work in just this way. The goal is to chain together a sequence of functions that transform the provided input into the desired output.
To practice this, I suggest tackling Proyecto Euler problems in your chosen functional language. If you have yet to choose a language, Haskell offers fewer non-functional distractions than most languages. However, consult otra pregunta SO para más opciones
After building a few functional pipelines, you will quickly find that you want to put functions together in ways more elaborate than simple chaining. This is where higher-level functions come into play, involving concepts like cartografía, plegable y zurra. After playing with those concepts, you might start to imagine even higher-level abstractions that go by names like monada y cirugía estética.
The key to this progression is to make sure that you restrict yourself to the functional style when tackling your practice problems. One way to do that is to force yourself to express solutions using only tácito (o sin puntos) formar.
Books aimed at beginner programmers teach the concepts and basics of functional programming along with a particular programming language. Books were my way into Lisp, ML/OCAML, and Haskell.
I'm not sure it's a matter of mindset. Some problems have cleaner solutions in pure functional and others in pure OO, etc. That's why many mainstream programming languages are evolving into multi-paradigm systems.
A personal opinion (something disliked here) is that it's easier to do functional in Python, C#, or Java, than it is to do statefull OO in Haskell, or OCAML. There are several hoops to jump before one even begins to grasp the concept and application of Mónadas.
Gives some details about the difference with procedural programming.
You might want to check more (popular) reading from Douglas R Hofstadter, who has based a few books on the functional programming language LISP.
“Goedel, Escher, Bach” by D.R. Hofstadter, and of course Metamagical Themas, that included a chapter about recursion, and the solution of the Towers of Hanoi in Lisp. Things I read when I was a teenager and that got me started on programming.
You may start with "How to design programs" by Felleisen et al. It's oriented towards problem solving, IIUC this is what you're after.