我已经广泛阅读了这个问题,但没有找到可用的解决方案.他们中的许多人建议从头开始重建python.如果可能的话,这是我想避免的障碍.因此,我将最后一次提出这个问题,绝望的射击.它不应该与stackoverflow上的许多类似问题重复,因为我认为它特定于我的安装,即使症状与其他类似.
这是我安装的当前状态.我已经安装了许多其他软件包numpy,有matplotlib没有问题,但这个问题让我感到困惑.
MacBookPro:lib-tk rebcabin$ arch -x86_64 /opt/local/bin/python
Python 2.7.3 (default, Nov 17 2012, 19:54:34)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', ...
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
...]
Run Code Online (Sandbox Code Playgroud)
注意lib-tk路径.我们来看看lib-tk:
MacBookPro:lib-tk rebcabin$ ls -la
total 3704
...
-rw-r--r-- 1 root wheel 155634 Nov 17 19:55 Tkinter.py
-rw-r--r-- 1 root wheel 224887 Nov 17 19:55 Tkinter.pyc
-rw-r--r-- 1 root wheel 224887 …Run Code Online (Sandbox Code Playgroud) 我想在一个字符串中发送一个clojure表达式,以便在接收者处进行评估,这可能是一个用compojure编写的Web服务.例如,假设我有字符串"(*7 6)",我想把它变成'(*7 6),然后我可以传递给eval并得到42.这个操作在JavaScript中是微不足道的,但是不太确定如何在clojure中做到这一点.提示?
我是C++ 11的新手,我正在尝试构建一个经典的接口/实现对.请考虑以下示例:
#include <iostream>
#include <memory>
// Interface
class IFace {
public:
virtual ~IFace () = 0;
};
// Why must I define this concrete implementation?
inline IFace::~IFace () { }
// Implementation
class Impl : public IFace {
public:
virtual ~Impl () { }
};
int main (int argc, char ** argv) {
auto impl = std::shared_ptr<Impl> (new Impl ());
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果我在界面上注释掉不需要的具体析构函数inline IFace::~IFace () { },我会收到链接错误
Undefined symbols for architecture x86_64:
"IFace::~IFace()", referenced from:
Impl::~Impl() …Run Code Online (Sandbox Code Playgroud) 我刚刚开始同时学习Java8流和Apache公共Math3,并寻找错过的机会来简化我的解决方案以比较实例的相等性.考虑一下这个Math3 RealVector:
RealVector testArrayRealVector =
new ArrayRealVector(new double [] {1d, 2d, 3d});
Run Code Online (Sandbox Code Playgroud)
并考虑这个包含盒装双精度的成员变量,以及它作为数组列表集合的副本:
private final Double [] m_ADoubleArray = {13d, 14d, 15d};
private final Collection<Double> m_CollectionArrayList =
new ArrayList<>(Arrays.asList(m_ADoubleArray));
Run Code Online (Sandbox Code Playgroud)
这是我在JUnit类中的功能样式(这里是完整的要点)中使用codepoetix中的protonpack来比较它们的最好结果,因为我找不到zip在Streams库中.这看起来真的很巴洛克风格,我想知道我是否错过了让它更短,更快,更简单,更好的方法,因为我刚刚开始学习这些东西并且不太了解.
// Make a stream out of the RealVector:
DoubleStream testArrayRealVectorStream =
Arrays.stream(testArrayRealVector.toArray());
// Check the type of that Stream
assertTrue("java.util.stream.DoublePipeline$Head" ==
testArrayRealVectorStream.getClass().getTypeName());
// Use up the stream:
assertEquals(3, testArrayRealVectorStream.count());
// Old one is used up; make another:
testArrayRealVectorStream = …Run Code Online (Sandbox Code Playgroud) 我有一个MVE程序,用g ++ - 5.2.0编译和运行,但没有使用clang-602.0.53.该程序尝试将lambda表达式分配给兼容类型的类型别名.
#include<iostream>
#include<complex>
using std::cout;
using std::endl;
using std::complex;
// type alias
using CfDD = complex<double> (*) (double);
// lambda of compatible type
auto theLambda = [] (double _) {return complex<double>({1,0});};
int main()
{ // Show that the lambda is callable:
cout << theLambda(3.14) << endl;
// Show that the lambda is assignable to a var of type CfDD
CfDD cfdd = theLambda;
cout << cfdd (3.14) << endl;
}
Run Code Online (Sandbox Code Playgroud)
使用g ++ - 5.2.0编译时,此程序有效:
$ g++-5 --version …Run Code Online (Sandbox Code Playgroud) 按照WITH-OUTPUT-TO-STRING和 GET-OUTPUT-STREAM-STRING的文档,我希望以下内容可以正常工作,它们可以:
(print
(with-output-to-string (sb nil)
(format sb "~A " "hello, ")
(format sb "~A~&" "world")
sb))
(print
(let ((sb (make-string-output-stream)))
(format sb "~A " "hello, ")
(format sb "~A~&" "world")
(get-output-stream-string sb)))
Run Code Online (Sandbox Code Playgroud)
但是,以下内容与WITH-OUTPUT-TO-STRING中的一个示例相近 ,不会:
(print
(with-output-to-string (sb (make-array
'(0)
:element-type 'base-char
:fill-pointer 0
:adjustable t))
(format sb "~A " "hello, ")
(format sb "~A~&" "world")
sb))
Run Code Online (Sandbox Code Playgroud)
相反,生成输出流本身,而不是生成的字符串:
#<SB-IMPL::FILL-POINTER-OUTPUT-STREAM {1005FBE523}>
Run Code Online (Sandbox Code Playgroud)
我一直无法找到在输出流中提取字符串的方法.我怀疑它与动态范围有关,但我的理解在这里踌躇不前.
显然,我有更好的方法来达到预期的结果,所以我只是好奇地发现我对语言的误解.
由于文件说,结果是不确定的,用于在流GET-OUTPUT-STREAM-STRING 不是由MAKE-STRING-OUTPUT-STREAM创建的,我并不感到惊讶,下面不工作:
(print
(with-output-to-string (sb (make-array
'(0)
:element-type 'base-char
:fill-pointer 0
:adjustable …Run Code Online (Sandbox Code Playgroud) 考虑以下功能
(defn shove [data fun] (eval `(-> ~data ~fun)))
Run Code Online (Sandbox Code Playgroud)
在这里按预期工作
(shove [1 2 3] count) ;; ~~> 3
Run Code Online (Sandbox Code Playgroud)
甚至在这里,它预计会失败,因为它评估(count)得为时过早
(shove [1 2 3] (count))
;; ~~> clojure.lang.Compiler$CompilerException: clojure.lang.ArityException:
;; Wrong number of args (0) passed to: core$count, compiling:(null:5:1)
Run Code Online (Sandbox Code Playgroud)
但是在这里,当我定义一个显式形式并将其作为数据传递给函数时,一切都很好:
(def move '(count))
(shove [1 2 3] move) ;; ~~> 3
Run Code Online (Sandbox Code Playgroud)
现在,为了摆脱对的显式调用eval,我尝试
(defmacro shovem [data form] `(-> ~data ~form))
Run Code Online (Sandbox Code Playgroud)
哪个很好
(shovem [1 2 3] count) ;; ~~> 3
(shovem [1 2 3] (count)) ;; ~~> …Run Code Online (Sandbox Code Playgroud) 我在Octave/Matlab中有一个函数,比如这个(真正的函数更复杂,更复杂)
function result = foo (x, y, z)
result = x + y + z;
endfunction
Run Code Online (Sandbox Code Playgroud)
调用该函数的常规方法如下:
foo (1, 2, 3);
Run Code Online (Sandbox Code Playgroud)
但我想将它应用于打包在数组中的参数,如下所示:
myStuff = [1, 2, 3];
apply (foo, myStuff);
Run Code Online (Sandbox Code Playgroud)
要么
foo (myStuff);
Run Code Online (Sandbox Code Playgroud)
我无法在文档或Google上找到此类调用所需的语法.
在Mac OSX 10.8,XCode 4.6,C++中
我下面的教程中opencv_tutorials.pdf,位于/opt/local/share/OpenCV/doc我的系统上.在页311,我们得到此示例(略有编辑):
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
int main( int argc, char** argv ) {
Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_1;
detector.detect( img_1, keypoints_1 );
}
Run Code Online (Sandbox Code Playgroud)
我不得不修改上面的代码,#include "opencv2/nonFree/features2d.hpp"通过运行找到的文件
find /opt/local/include -name "*.hpp" -exec grep SurfFeatureDetector "{}" ';' -print
Run Code Online (Sandbox Code Playgroud)
代码编译,意味着符号detector.detect在hpp文件中找到并通过C++编译器进行类型检查.接下来是尝试查找包含符号的库.
现在,我在我的发行版中有这些库/opt/local/lib:
libopencv_calib3d.2.4.3.dylib
libopencv_contrib.2.4.3.dylib
libopencv_core.2.4.3.dylib
libopencv_features2d.2.4.3.dylib
libopencv_flann.2.4.3.dylib
libopencv_gpu.2.4.3.dylib …Run Code Online (Sandbox Code Playgroud) 我们希望完全从组织模式的babel文件中自动生成Leiningen项目树.我们希望这样做,以便我们也可以通过创建漂亮的排版文档
org-latex-export-to-pdf.我们希望在org-mode中使用Clojure中的完整文字编程.
以下命令:
$ lein new ex1
Run Code Online (Sandbox Code Playgroud)
生成一个如下所示的树:
ex1
ex1/.gitignore
ex1/doc
ex1/doc/intro.md
ex1/project.clj
ex1/README.md
ex1/resources
ex1/src
ex1/src/ex1
ex1/src/ex1/core.clj
ex1/test
ex1/test/ex1
ex1/test/ex1/core_test.clj
Run Code Online (Sandbox Code Playgroud)
我们想通过org-babel-tangle在emacs中的org-mode缓冲区中运行而不再执行相同
的操作.
一个难题出现了:而tangle高兴地产生像现有的子目录中的文件src和test,似乎不愿意生产子目录,如果它们不存在.这意味着我们必须通过其他方式创建目录结构 - 除非我们能够tangle为我们做到这一点,这就是StackOverflow问题的主题
.
目录结构中有六个文件Leiningen.我可以将它们全部删除,然后BEGIN_SRC使用以下块来从我的org文件重新创建它们
#+BEGIN_SRC clojure :tangle ./ex1/src/ex1/core.clj
(ns ex1.core)
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
#+END_SRC
Run Code Online (Sandbox Code Playgroud)
特别注意子目录路径的名称
#+BEGIN_SRC clojure :tangle ./ex1/src/ex1/core.clj
Run Code Online (Sandbox Code Playgroud)
如果我们的目录结构已经存在,一切都很好.org-mode tangle将创建或更新上述所有六个文件,并在任何现有目录中创建新文件.我们不知道如何tangle制作目录; 它抱怨说没有这样的目录.
如果您想了解更多详细信息,.org可在此处 …