在莱宁根哪里可以找到依赖项的有效版本号

发布于 2024-11-05 21:34:42 字数 773 浏览 0 评论 0 原文

我是 Clojure 和 Leiningen 的新手,并且我确定我想要使用的一些内容位于 clojure.contrib.generic.math-functions 中。我在 http://richhickey 找到了相关的 API 信息。 github.com/clojure-contrib/branch-1.1.x/math-api.html,但我找不到任何可以帮助我弄清楚应该将哪些内容放入我的 project.clj 文件中的内容依赖性。

我已经尝试过[clojure.contrib.generic.math-functions“1.1”][clojure.contrib.generic.math-functions“1.1.x”],并且[clojure.contrib.generic.math-functions“1.1.0”]。对于每一个,我都会得到类似......

...
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
----------
1) clojure.contrib.generic.math-functions:clojure.contrib.generic.math-functions:jar:1.1

I'm new to Clojure and Leiningen, and I've determined that some of what I'll want to use is located in clojure.contrib.generic.math-functions. I found API information for that at http://richhickey.github.com/clojure-contrib/branch-1.1.x/math-api.html, but I can't find anything that helps me figure out what I should put into my project.clj file for that dependency.

I have tried [clojure.contrib.generic.math-functions "1.1"], [clojure.contrib.generic.math-functions "1.1.x"], and [clojure.contrib.generic.math-functions "1.1.0"]. For each of those, I get something like...

...
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
----------
1) clojure.contrib.generic.math-functions:clojure.contrib.generic.math-functions:jar:1.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

音盲 2024-11-12 21:34:42

所有 clojure-contrib 命名空间都包含在单个 jar 文件中,必须列出该文件的依赖项,如下所示:

[org.clojure/clojure-contrib "1.2.0"]

请注意,该工件有不同的版本可用。 1.2.0 是当前的稳定版本。

为了在 clojure 代码中使用来自 math-functions 命名空间的函数,您需要 要求使用这样的命名空间,通常在源文件开头的 ns 形式中完成:

(ns my.namespace
    (:use [clojure.contrib.generic.math-functions]))

看看 此处查看 userequire< 之间的区别/代码>。

All clojure-contrib namespaces are shipped within a single jar file, for which the dependency has to be listed like:

[org.clojure/clojure-contrib "1.2.0"]

Please note that there are different versions available of that artifact. The 1.2.0 is the current stable release.

In order to use functions coming from the math-functions namespace in your clojure code, you need to either require or use such namespace, usually done within the ns form at the beginning of your source file:

(ns my.namespace
    (:use [clojure.contrib.generic.math-functions]))

Have a look here to see the differences between use and require.

極樂鬼 2024-11-12 21:34:42

Leiningen 的下一个版本将为此目的提供搜索任务。它将搜索 Clojars、Maven Central 以及您的项目列出的任何其他存储库,前提是它们提供可下载的索引。它已经实现了,所以如果你从 git 运行 Leiningen 就可以使用它。

此外,Leiningen 教程也涵盖了这一点。输入“lein帮助教程”。

The next version of Leiningen will have a search task for precisely this purpose. It will search Clojars, Maven Central, and any other repositories your project has listed, provided they offer up downloadable indices. It's already implemented, so if you run Leiningen from git you can use it.

Also, the Leiningen tutorial covers this. Type "lein help tutorial".

﹎☆浅夏丿初晴 2024-11-12 21:34:42

您通常可以在 clojars.org 找到您需要的内容 - 它是 leiningen 的默认存储库。 Clojure 当前的稳定版本是 1.2.0,因此您的 leiningen project.clj 中应包含此版本:

[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]

要在 clojure 中使用通用数学函数,require 或在源文件顶部的命名空间声明中use它:

(ns your-namespace
    (:use [clojure.contrib.generic.math-functions :as mathf]))

这允许您引用该命名空间中的函数,如下所示:

(mathf/abs -10) ;; => 10

:use-ing namespaces with :as 是在代码中使用其他命名空间中的函数的首选方法。 require 没问题,但是您必须在函数前面加上整个命名空间(例如 clojure.contrib.generic.math-functions/abs),所以这是不切实际的。使用不带 :as 的命名空间允许您在没有任何前缀的情况下使用这些函数(例如 abs),但您更有可能出现命名空间冲突,并且可能是很难看出函数来自哪里,特别是当您:use许多库时。

您可以通过查看 http://clojars.org/repo/ 浏览默认 leiningen 存储库中可用的所有库。 1.3.0 发布后,clojure-contrib 的结构将会发生变化,因此,如果您使用的是 1.3.0-alpha-xx 版本,则必须包含特定的 contrib 库:

[org.clojure.contrib/generic "1.3.0-alpha4"]

You can generally find what you need at clojars.org - it's the default repository for leiningen. The current stable release of Clojure is 1.2.0, so you'd have this in your leiningen project.clj:

[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]

To use the generic math functions in your clojure, require or use it in your namespace declaration at the top of your source file:

(ns your-namespace
    (:use [clojure.contrib.generic.math-functions :as mathf]))

This allows you to refer to the functions in that namespace like this:

(mathf/abs -10) ;; => 10

:use-ing namespaces with :as is the preferred way to use functions from other namespaces in your code. require is ok, but you'd have to prefix your functions with the entire namespace (e.g. clojure.contrib.generic.math-functions/abs) so that's not practical. Using a namespace without :as allows you to use these functions without any prefix at all (e.g. abs), but you're more likely to get namespace clashes and it might be difficult to see where functions come from, especially if you :use many libraries.

You can browse all libraries available from the default leiningen repository by checking out http://clojars.org/repo/. The structure of clojure-contrib will change when 1.3.0 is out, so you'll have to include the specific contrib library if you're using version 1.3.0-alpha-xx:

[org.clojure.contrib/generic "1.3.0-alpha4"]
拧巴小姐 2024-11-12 21:34:42

现在 clojure.contrib 已经被分解,数学函数位于名为 math.numeric-tower 的东西中。 lein 依赖项指定如下:

[org.clojure/math.numeric-tower "0.0.1"]

您可以根据需要使用或要求,例如

(use '[clojure .math.numeric-tower])

Now that the clojure.contrib has been broken up, the math functions are in something called math.numeric-tower. The lein dependency is specified like this:

[org.clojure/math.numeric-tower "0.0.1"]

You can use or require as seems appropriate, for example

(use '[clojure.math.numeric-tower])

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