有没有一个网站可以查找常用的、已编写的函数?

发布于 2024-09-01 00:43:51 字数 437 浏览 1 评论 0原文

我坐在这里写一个函数,我确信以前在地球上的某个地方已经写过这个函数。这种情况太常见了,以至于没有人尝试过,我想知道为什么我不能直接访问网站并搜索一个功能,然后在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

公布 2024-09-08 00:43:51

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.

阳光下的泡沫是彩色的 2024-09-08 00:43:51

首先,有两个警告:

  1. 复制并粘贴您不理解的代码是一个坏主意。在使用代码之前,请确保您准确理解该代码的用途。
  2. 确保您尊重所复制代码的许可。这很重要!

抛开这些注意事项不谈,它通常依赖于语言。具有开放开发精神的语言(不仅仅是开源实现,例如与 Java 相比,Python)往往拥有开源库的官方档案。例如:

此外,不要忘记查看您的语言标准库。一些现代语言拥有大量标准库,其中通常包含我正在寻找的功能:

非开放开发的语言通常有非官方的社区档案。例如:

第三类网站与语言无关。它们通常最好通过 POG(普通老式谷歌)进行搜索。例如:

最后是第四类我发现源代码搜索引擎越来越有用:

您还可以通过各种pastebins找到有用的源代码,或者至少获得编写一些东西的帮助。

  • Pastebin 与语言无关
  • HPaste 主要是 Haskell,但也有一些其他语言的。

不过,通常情况下,在一天结束时,最简单的方法就是用谷歌搜索。

Firstly, two caveats:

  1. Copy and pasting code you don't understand is a bad idea. Make sure you understand exactly what the code does before you use it.
  2. Make sure you respect the license of the code you are copying. This is important!

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.

  • Pastebin is language-agnostic
  • HPaste is mostly Haskell, but has a little in other languages.

Often, at the end of the day it is easiest just to google it, though.

逆蝶 2024-09-08 00:43:51

有一个 wiki,其中包含任何人都可以编辑和改进的免费代码:

Rosetta 代码

作为概述的一种方式,有“按编程任务列出的解决方案”页面。


从上一页:

“Rosetta Code 是一个编程chrestomathy 网站。
想法是提出相同任务的解决方案
尽可能使用多种不同的语言来演示
语言如何相似和不同,并帮助
以一种方法解决问题的人
学习另一个。”

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:

"Rosetta Code is a programming chrestomathy site. The
idea is to present solutions to the same task in as
many different languages as possible, to demonstrate
how languages are similar and different, and to aid a
person with a grounding in one approach to a problem
in learning another."

始终不够爱げ你 2024-09-08 00:43:51

将在互联网上找到的代码剪切并粘贴到生产代码中就像在街上找到口香糖一样。 - Mike Johnson

考虑到这一点,请尝试托管开源项目的网站,例如 GitHubCodePlex、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.

一瞬间的火花 2024-09-08 00:43:51

我不确定这个问题是否与语言无关,但我以这种方式使用 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.

伪装你 2024-09-08 00:43:51

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.

李不 2024-09-08 00:43:51

除了像这个(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文