有没有一个网站可以查找常用的、已编写的函数?
我坐在这里写一个函数,我确信以前在地球上的某个地方已经写过这个函数。这种情况太常见了,以至于没有人尝试过,我想知道为什么我不能直接访问网站并搜索一个功能,然后在 2 秒内将其复制并粘贴到我的项目中,而不是浪费时间重新发明轮子。
当然,您可以使用某些库,但是您在哪里可以找到这些库,当它们不存在时,是否有像我描述的那样的网站?
可能是某种类型的 wiki,其中包含任何人都可以编辑和改进的免费代码?
编辑:我可以很好地编写代码,我只是不知道该怎么做。例如,现在,我正在尝试定位空间中的机器人/汽车/点。我知道有一种方法可以做到这一点,只需根据范围和距离即可。三角测量和三边测量。如何编码是一个不同的故事。一个可能有伪代码的网站,一步一步地说明如何做到这一点将非常有帮助。它还将确保最佳解决方案,因为每个人都可以编辑它。我也在用 Matlab 写作,我讨厌它,因为它很古怪,这增加了我创建一个像我所描述的网站的愿望。
I'm sitting here writing a function that I'm positive has been written before, somewhere on earth. It's just too common to have not been attempted, and I'm wondering why I can't just go to a website and search for a function that I can then copy and paste into my project in 2 seconds, instead of wasting my day reinventing the wheel.
Sure there are certain libraries you can use, but where do you find these libraries and when they are absent, is there a site like I'm describing?
Possibly a wiki of some type that contains free code that anybody can edit and improve?
Edit: I can code things fine, I just don't know HOW to do them. So for example, right now, I'm trying to localize a robot/car/point in space. I KNOW there is a way to do it, just based off of range and distance. Triangulation and Trilateration. How to code that is a different story. A site that could have psuedo code, step by step how to do that would be ridiculously helpful. It would also ensure the optimal solution since everybody can edit it. I'm also writing in Matlab, which I hate because it's quirky, adding to my desire for creating a website like I describe.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
StackOverflow.com。不,我不是在开玩笑。
在最好的情况下,人们来这里会说“某个图书馆还没有完成某项工作吗”,而集体智慧通常会回答“是”。但最大的障碍是缺乏描述语言:即使在这里,对于许多发帖者来说,一个大问题是足够清楚地描述问题,以便其他人能够将其识别为他们以前见过的东西。
如果人们无法理解您想要做什么,那么任何搜索引擎都不会。
StackOverflow.com. No, I'm not joking.
At its best, people come here saying "hasn't some library done X already", and very often the Collective Wisdom answers "yes". But the biggest obstacle is lack of a description language: even here, a big problem for many posters is describing the problem clearly enough for others to recognize it as something they've seen before.
And if people can't understand what you're trying to do, no search engine will.
首先,有两个警告:
抛开这些注意事项不谈,它通常依赖于语言。具有开放开发精神的语言(不仅仅是开源实现,例如与 Java 相比,Python)往往拥有开源库的官方档案。例如:
此外,不要忘记查看您的语言标准库。一些现代语言拥有大量标准库,其中通常包含我正在寻找的功能:
非开放开发的语言通常有非官方的社区档案。例如:
第三类网站与语言无关。它们通常最好通过 POG(普通老式谷歌)进行搜索。例如:
最后是第四类我发现源代码搜索引擎越来越有用:
您还可以通过各种pastebins找到有用的源代码,或者至少获得编写一些东西的帮助。
不过,通常情况下,在一天结束时,最简单的方法就是用谷歌搜索。
Firstly, two caveats:
Those caveats aside, it's often language dependent. Languages with an open development ethos (not just an open source implementation, think Python as compared to Java) tend to have official archives of open source libraries. For example:
Furthermore, don't forget to look in your languages standard library. Some modern languages have massive standard libraries, which have often contained the functionality I am looking for:
Non-openly developed languages often have non-official community archives. For example:
A third category of sites are language agnostic. They are often best search through POG (plain old-fashioned Google). For example:
Finally, a fourth category of sites that I find increasingly useful are source-code search engines:
You may also be able to find useful source code, or at least get help writing something, through various pastebins.
Often, at the end of the day it is easiest just to google it, though.
有一个 wiki,其中包含任何人都可以编辑和改进的免费代码:
Rosetta 代码。
作为概述的一种方式,有“按编程任务列出的解决方案”页面。
从上一页:
There is a wiki that contains free code that anybody can edit and improve:
Rosetta Code.
As a means of an overview there is the "Solutions by Programming Task" page.
From the former page:
将在互联网上找到的代码剪切并粘贴到生产代码中就像在街上找到口香糖一样。 - Mike Johnson
考虑到这一点,请尝试托管开源项目的网站,例如 GitHub、CodePlex、code.google.com 等。
Cutting and pasting code you find on the Internet into production code would be like chewing gum found in the street. - Mike Johnson
With that in mind, try sites that host opensource projects like GitHub, CodePlex, code.google.com, etc.
我不确定这个问题是否与语言无关,但我以这种方式使用 GitHub ;)其他语言可能有这样的地方。
I'm not sure this question is language agnostic, but I use GitHub this way ;) Other languages may have places where this is possible.
O'Reilly 的 Safari Bookshelf 有很多很多书籍,其中包含许多可供选择的实现。
http://my.safaribooksonline.com/
在来到我现在的网站之前,我已经订阅了几年工作,我们有一个公司帐户!这是最好的福利之一,也是我拥有的最好的资源之一。我已经很多年没有买电脑书了。
Safari Bookshelf from O'Reilly has many, many books that contain many implementations from which to choose.
http://my.safaribooksonline.com/
I was a subscriber for a few years before coming to my current job, where we have a corporate account! It's one of the best perks, and one of the best resources I have available. I haven't bought a computer book in years.
除了像这个(Stack Overflow)这样的网站之外,我认为没有很多,也许CodePlex< /a>,但我几乎把你标记为-1,因为你假设在互联网上找到的代码是你可以复制的。
我建议您阅读有关软件许可的内容,我希望您至少能评论一下您从哪里获得它。
Aside from sites like this (Stack Overflow) I don't think there's many, maybe CodePlex, but I almost marked you -1 for assuming that code found on the Internet is yours to copy.
I'd suggest reading about software licencing, I hope you'd at least comment where you got it from.