In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you the process of comparing the related technologies of Python function and Ruby. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
There are a lot of interesting things about Python functions in everyday use. Let's take a detailed look at the technical comparison between Python functions and Ruby. Let's take a look at how to apply it. I hope you all get something.
What is the use of Python functional programming? I think the practical benefit is that the problem itself can be better described rather than the steps to solve the problem. Look at a specific example:
Problem: a list; squared for each element; the number squared is removed from the list if the remainder of dividing 3 is 1.
Look at the solution:
1. Traditional procedure (Python function)
> s = [1 if I * I% 3! = 1: d.append (I * I) > d [9] > d [9] > >
two。 Traditional function (Lisp)
(remove-if (lambda (n) (= (mod n 3) 1)) (mapcar (lambda (n) (* n n))'(1 2 3)
It can be seen that the functional program well corresponds to the two steps of our question, which are realized by mapcar and remove-if respectively. But Lisp's program is really hard to read, so let's use python and ruby to improve it:
3. Python function:
> filter (lambda n% 3! = 1, map (lambda n:n*n, [1pm 2pm 3])) [9]
4. Ruby function:
] .map {| n | n * n} .reject {| n | n% 3 = = 1} = > [9]
By comparison, ruby is the most concise and the most natural corresponding to the problem description.
The above is the editor for you to share the Python function and Ruby related technology comparison process, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.