Is there any good book for functional programming in Python or C++ ? I need to master functional programming in those languages.
在Python或C ++中有没有关于函数式编程的好书?我需要掌握这些语言的函数式编程。
7 个解决方案
#1
6
By functional programming, I assume you mean referential transparency (basically, no global state or side-effects), plus things like functions as first-class objects, polymorphic types, partial function application etc.
通过函数式编程,我假设你指的是引用透明度(基本上没有全局状态或副作用),加上像第一类对象,多态类型,部分函数应用等函数。
There is no book that I know of that covers functional programming in C++. You could program without global state and side-effects in C++, and you can pass functions as arguments using function-typed pointers, but you couldn't get partial function application, nor anonymous lambda expressions.
我所知道的书中没有涉及C ++中的函数式编程。您可以在C ++中编写没有全局状态和副作用的程序,并且可以使用函数类型指针将函数作为参数传递,但是您无法获得部分函数应用程序,也无法获得匿名lambda表达式。
#2
6
Text Processing in Python uses a functional style, and is what turned me on to functional programming. It's also a great Python/programming book in general, and I highly recommend it.
Python中的文本处理使用了一种功能风格,这使我开始进行函数式编程。它也是一本很棒的Python /编程书,我强烈推荐它。
#3
3
MMhh if you want to learn functional programming you should learn a functional language first to really understand the principals then you can tree to apply them as good as you can, witch will be harder.
MMhh如果你想学习函数式编程,你应该首先学习一种函数式语言来真正理解这些函数,然后你就可以将它们尽可能地应用到树上,这将会更加困难。
In python you can use functions to modify dictionarys witch is pretty functional. Make use of lambda with higher order function. You have to avoid classes and inheritance.
在python中你可以使用函数来修改dictionarys女巫非常实用。利用具有更高阶函数的lambda。你必须避免类和继承。
I cant really say much about C++. Maybe you can find some functional datastructures and then write functions on those. Look for a library that provides functions like map, reduce ...
我真的不太关于C ++。也许你可以找到一些功能数据结构,然后在那些上编写函数。寻找一个提供map,reduce等功能的库...
C++0x should support closures and currying (more or less) so thing will get better.
C ++ 0x应该支持闭包和currying(或多或少),所以事情会变得更好。
In general:
- Try to write immutible layers on librarys (be awair that that wont performe to well)
- Look for librarys that are written in a functional way
尝试在图书馆上写下不朽的图层(那是不会很好的表现)
寻找以功能方式编写的库
Edit: I would recomend learning scheme its really small and you can pick it up fast. Read something like SICP or the Little Schemer that teach you recursiv thinking.
编辑:我会建议学习计划非常小,你可以快速拿起它。阅读像SICP或Little Schemer这样教你递归思维的东西。
#4
1
Only a future version of C++ supports lambdas / anonymous functions. I guess Boost.Lambda supports C++ Functional programming, but it isn't really a first-class citizen of C++ yet.
只有未来版本的C ++才支持lambda / anonymous函数。我想Boost.Lambda支持C ++ Functional编程,但它还不是C ++的一流公民。
Books about functional programming typically use functional languages. Like Haskell, Miranda, Lisp, Scheme, OCaml, Javascript and so forth.
关于函数式编程的书通常使用函数式语言像Haskell,Miranda,Lisp,Scheme,OCaml,Javascript等等。
EDIT: I'll withhold my opinion on Python for now. It appears I'm mistaken about a few things.
编辑:我现在暂不支持我对Python的看法。看来我错了几件事。
#5
0
In looking for info on functional programming in Python, I've found this web page to be very useful:
在寻找Python中函数式编程的信息时,我发现这个网页非常有用:
http://www.amk.ca/python/writing/functional
The references part contains a lot of crude information.
引用部分包含大量原始信息。
If you are looking for a book covering only functional programming in Python, I don't know about it.
如果你正在寻找一本只涉及Python函数式编程的书,我不知道。
C++ is more difficult. It has many of the ingredients (and it is steadily gaining more) for functional programming, but lacks many others. Actually, C++ was never designed for supporting functional programming, so it is typical that you'll be able to work with functional programming in some containers, but need to revert to imperative programming frequently.
C ++更难。它有很多成分(而且它正在稳步增长)用于函数式编程,但缺少许多其他成分。实际上,C ++从未设计用于支持函数式编程,因此通常您可以在某些容器中使用函数式编程,但需要经常恢复命令式编程。
#6
0
While not a book, here is a site that can at least get you started on some things. http://www.ibm.com/developerworks/library/l-prog.html
虽然不是一本书,但这里有一个至少可以让你开始做某些事情的网站。 http://www.ibm.com/developerworks/library/l-prog.html
As far as really understanding functional programming I would suggest something like "The Little Schemer" to get a quick handle on scheme. You can then apply the ideas to python.
至于真正理解函数式编程,我会建议像“The Little Schemer”这样的东西来快速处理方案。然后,您可以将这些想法应用于python。
#7
-1
For Perl, I can recommend "Higher Order Perl".
对于Perl,我可以推荐“高阶Perl”。
Don't know about Python or C++ though.
但是不知道Python或C ++。
#1
6
By functional programming, I assume you mean referential transparency (basically, no global state or side-effects), plus things like functions as first-class objects, polymorphic types, partial function application etc.
通过函数式编程,我假设你指的是引用透明度(基本上没有全局状态或副作用),加上像第一类对象,多态类型,部分函数应用等函数。
There is no book that I know of that covers functional programming in C++. You could program without global state and side-effects in C++, and you can pass functions as arguments using function-typed pointers, but you couldn't get partial function application, nor anonymous lambda expressions.
我所知道的书中没有涉及C ++中的函数式编程。您可以在C ++中编写没有全局状态和副作用的程序,并且可以使用函数类型指针将函数作为参数传递,但是您无法获得部分函数应用程序,也无法获得匿名lambda表达式。
#2
6
Text Processing in Python uses a functional style, and is what turned me on to functional programming. It's also a great Python/programming book in general, and I highly recommend it.
Python中的文本处理使用了一种功能风格,这使我开始进行函数式编程。它也是一本很棒的Python /编程书,我强烈推荐它。
#3
3
MMhh if you want to learn functional programming you should learn a functional language first to really understand the principals then you can tree to apply them as good as you can, witch will be harder.
MMhh如果你想学习函数式编程,你应该首先学习一种函数式语言来真正理解这些函数,然后你就可以将它们尽可能地应用到树上,这将会更加困难。
In python you can use functions to modify dictionarys witch is pretty functional. Make use of lambda with higher order function. You have to avoid classes and inheritance.
在python中你可以使用函数来修改dictionarys女巫非常实用。利用具有更高阶函数的lambda。你必须避免类和继承。
I cant really say much about C++. Maybe you can find some functional datastructures and then write functions on those. Look for a library that provides functions like map, reduce ...
我真的不太关于C ++。也许你可以找到一些功能数据结构,然后在那些上编写函数。寻找一个提供map,reduce等功能的库...
C++0x should support closures and currying (more or less) so thing will get better.
C ++ 0x应该支持闭包和currying(或多或少),所以事情会变得更好。
In general:
- Try to write immutible layers on librarys (be awair that that wont performe to well)
- Look for librarys that are written in a functional way
尝试在图书馆上写下不朽的图层(那是不会很好的表现)
寻找以功能方式编写的库
Edit: I would recomend learning scheme its really small and you can pick it up fast. Read something like SICP or the Little Schemer that teach you recursiv thinking.
编辑:我会建议学习计划非常小,你可以快速拿起它。阅读像SICP或Little Schemer这样教你递归思维的东西。
#4
1
Only a future version of C++ supports lambdas / anonymous functions. I guess Boost.Lambda supports C++ Functional programming, but it isn't really a first-class citizen of C++ yet.
只有未来版本的C ++才支持lambda / anonymous函数。我想Boost.Lambda支持C ++ Functional编程,但它还不是C ++的一流公民。
Books about functional programming typically use functional languages. Like Haskell, Miranda, Lisp, Scheme, OCaml, Javascript and so forth.
关于函数式编程的书通常使用函数式语言像Haskell,Miranda,Lisp,Scheme,OCaml,Javascript等等。
EDIT: I'll withhold my opinion on Python for now. It appears I'm mistaken about a few things.
编辑:我现在暂不支持我对Python的看法。看来我错了几件事。
#5
0
In looking for info on functional programming in Python, I've found this web page to be very useful:
在寻找Python中函数式编程的信息时,我发现这个网页非常有用:
http://www.amk.ca/python/writing/functional
The references part contains a lot of crude information.
引用部分包含大量原始信息。
If you are looking for a book covering only functional programming in Python, I don't know about it.
如果你正在寻找一本只涉及Python函数式编程的书,我不知道。
C++ is more difficult. It has many of the ingredients (and it is steadily gaining more) for functional programming, but lacks many others. Actually, C++ was never designed for supporting functional programming, so it is typical that you'll be able to work with functional programming in some containers, but need to revert to imperative programming frequently.
C ++更难。它有很多成分(而且它正在稳步增长)用于函数式编程,但缺少许多其他成分。实际上,C ++从未设计用于支持函数式编程,因此通常您可以在某些容器中使用函数式编程,但需要经常恢复命令式编程。
#6
0
While not a book, here is a site that can at least get you started on some things. http://www.ibm.com/developerworks/library/l-prog.html
虽然不是一本书,但这里有一个至少可以让你开始做某些事情的网站。 http://www.ibm.com/developerworks/library/l-prog.html
As far as really understanding functional programming I would suggest something like "The Little Schemer" to get a quick handle on scheme. You can then apply the ideas to python.
至于真正理解函数式编程,我会建议像“The Little Schemer”这样的东西来快速处理方案。然后,您可以将这些想法应用于python。
#7
-1
For Perl, I can recommend "Higher Order Perl".
对于Perl,我可以推荐“高阶Perl”。
Don't know about Python or C++ though.
但是不知道Python或C ++。