1) Map takes a function and a sequence as input, applies the function to each input in the sequence, and then returns whatever the function returns for each. Filter is similar to map in that it takes a function and a sequence as input, but it only returns values of the function that are true (1). Reduce takes a function and a sequence as input and returns the combined results.
2) Functional programming is very powerful in that you can do a lot with very few lines of code.
3) People use functional programming in artificial intelligence and building prototypes of systems.
4) Multiple functions makes a program easier to debug, easier for others to follow or edit later, and helps in writing new programs because you can use trusted, useful functions already written.
5 is a repeat of #4 incase whoever wrote this didnt catch that
... what about recursion??? Is recursion supposed to be included in the answer somehwere?
yes. It could be included to either q2 or q4. Why would it be important in terms of functional programming? Student56
Recursion
See RECURSION. Recursion
Recursion
See RECURSION. Recursion
Recursion
See RECURSION. Recursion
Recursion
See RECURSION. Recursion
Recursion
(this is from a glossary- the hitchhiker's guide to the galaxy- http://www.dwave.net/~tony/Mars/hgttg2.htm#Ref60 )
To use a function in another function and apply that same function to all the inputs. Pls. correct me if I am wrong for q2.
recursion: a function calling itself
it makes it easier to write functions if you can "trust" it to work...
Same ideas...different wording. Answer to 4) is a little different.
1)
i. Map- takes a function and a sequence and inputs all values of the sequence into the function. Each output value is returned.
ii. Filter- This does the same as map, but returns only the output values that the program denotes are true.
iii. Reduce- Takes a function and sequence input and returns combined results.
2)Functional programming gives you REMOVED bang for your buck; REMOVEDss coding with a greater number of outputs/results. Programming recursively amounts to exponential results when compared to the amount of code and effort the programmer puts in.
3)Functional programming is used in creating AI and automated systems, aka, computer-programmed robots in a factory that do tasks over and over again.
4)
i) Easier to debug
ii) Easier to modify/edit upon and not convolute the whole program
iii) With multiple functions, one can extract useful subfunctions and use that operation in an entirely new program.
iiii)Multiple functions allow viewers to understand the whole algorithm, piece by piece.