我是C的新手,在OS X中编译代码时遇到了一些问题.
我在Eclipse中编写了很多Java代码,并使用终端编译我的代码.但是现在我正在学习openMP并且遇到麻烦.
首先我下载了Xcode来编写openMP代码,但它无法识别<omp.h>.然后我安装了g++.当我输入g++ -v终端时,我得到了这个:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
Run Code Online (Sandbox Code Playgroud)
但是当我使用时,g++ Mesh.cpp -fopenmp我仍然会得到
Mesh.cpp:4:10: fatal error: 'omp.h' file not found
#include <omp.h>
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
然后我尝试将PTP安装到Eclipse中并遇到同样的问题.我以为omp.h我的MacBook 中没有,所以我搜索了它,发现下面有几个omp.h文件夹gcc-4.9.1/build/.
这就是问题所在.根据Java经验,我拥有该文件但无法使用它的唯一原因是类路径错误.但是,我不知道如何在g ++,Xcode或Eclipse中更改此配置.但是因为我可以包含<stdio.h>所有IDE的文件并使用所有IDE编译它,我怎么能不这样做<omp.h>呢?
我注意到的另一件事是gcc文件夹版本是4.9.1,但当我输入gcc -v终端时,我输入相同的内容g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on …Run Code Online (Sandbox Code Playgroud) 我一直在阅读一些材料,在这里我有一个问题:我看到一段代码是这样的:
>getNthElem 1 xs = head xs
>getNthElem n [] = error "'n' is greater than the length of the list"
>getNthElem n xs
> | n < 1 = error "'n' is non-positive"
> | otherwise = getNthElem (n-1) (tail xs)
Run Code Online (Sandbox Code Playgroud)
我应该将所有这些行完全相同地输入到ghci中,还是应该创建一个.hs文件并将其放入,然后将其加载到ghci中?
我正在尝试使用Stanford CoreNLP作为我的java程序中的库.我使用IntelliJ作为IDE.我试图测试库,所以我写了这段代码:
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import java.util.Properties;
/**
* Created by Benjamin on 15/5/4.
*/
public class SentimentAnaTest {
public static void main(String[] args) {
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
}
}
Run Code Online (Sandbox Code Playgroud)
它显示如下错误:
Adding annotator tokenize
TokenizerAnnotator: No tokenizer type provided. Defaulting to PTBTokenizer.
Adding annotator ssplit
Adding annotator pos
Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model
at edu.stanford.nlp.pipeline.AnnotatorFactories$4.create(AnnotatorFactories.java:292)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85)
at …Run Code Online (Sandbox Code Playgroud) 嗨,我是Haskell编程的新手.我正在尝试自己实现运算符"++".这是我写的一个小程序,但它不起作用:
append (es:e) xs =
if (null es)
then e:xs
else append es (e:xs)
Run Code Online (Sandbox Code Playgroud)
我收到了很多关于[a],[[a]]和[[[a]]]的类型错误.关于Haskell中的列表类型仍然令人困惑.有人可以帮助我吗?谢谢.:)
我正在尝试TypeScript 中的React Router 教程。该代码有效,但我发现很难识别参数的类型定义,例如
export async function action({ request, params }) {
const formData = await request.formData();
const updates = Object.fromEntries(formData);
...
Run Code Online (Sandbox Code Playgroud)
从调试中我可以看到该变量request是 的类型Request,但是在尝试导入时我找不到这样的类型。
关于参数的类似问题params。
有人可以帮助困惑的 .NET C# 开发人员吗?
Prelude> :t (+)
(+) :: (Num a) => a -> a -> a
Run Code Online (Sandbox Code Playgroud)
我的演讲幻灯片说
a -> a -> a
Run Code Online (Sandbox Code Playgroud)
表示函数接受两个参数并返回一个,并且它们都是相同的类型.哪两个是参数,哪一个是返回值?
谢谢.
我正在尝试编写一个行为如下的函数:
correctCards :: [Card] -> [Card] -> Int
Run Code Online (Sandbox Code Playgroud)
它需要两个类型卡列表并检查有多少卡是相同的.这是我的代码:
correctCards answer guess = foldr step acc guess
where
acc = 0
step acc guess
| elem (head guess) answer = acc + 1
| otherwise = acc
Run Code Online (Sandbox Code Playgroud)
但类型不匹配.谁能告诉我哪里出错了?谢谢.
我想在Haskell中写这样的东西:
length . nub . intersect
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
*Main Data.List> :t intersect
intersect :: Eq a => [a] -> [a] -> [a]
*Main Data.List> :t nub
nub :: Eq a => [a] -> [a]
*Main Data.List> :t length
length :: [a] -> Int
Run Code Online (Sandbox Code Playgroud)
根据上式,我的理解是,intersect返回类型[a],并捐赠给nub,这恰恰是一个类型的[a],然后也返回一个类型[a]来length,最后返回应该是一个Int.它出什么问题了?
haskell combinators pointfree function-composition dot-operator
我一直在读我的教科书,这里有些困扰我:其中一个页面显示了这样的代码:
-- file: ch02/add.hs
add a b = a + b
Run Code Online (Sandbox Code Playgroud)
然后将其加载到ghci中.但是,当我输入第一行ghci时,它什么也没做,然后第二行触发了一个错误.
我想这两行意味着我应该创建一个文件并将其放入,然后加载它.但ghci告诉我它无法识别" - ",尽管第二行表现良好.所以我很困惑:不应该" - "意思是"//"?我误解了教科书了吗?
谢谢.
我正在尝试理解这段代码:
search_bst :: Tree -> String -> Maybe Int
search_bst Leaf _ = Nothing
search_bst (Node k v l r) sk =
if sk == k then Just v
else if sk < k then search_bst l sk
else search_bst r sk
Run Code Online (Sandbox Code Playgroud)
我可以得到这个概念但是Node k v l r意味着什么?这是否意味着search_bst需要两个参数,第一个是类型的实例Node并且有三个值?
-- file: ch03/BogusPattern.hs
data Fruit = Apple | Orange
deriving (Show)
apple = "apple"
orange = "orange"
whichFruit :: String -> Fruit
whichFruit f = case f of
"apple" -> Apple
"orange" -> Orange
Run Code Online (Sandbox Code Playgroud)
在这段代码中我为什么需要
apple = "apple"
orange = "orange"
Run Code Online (Sandbox Code Playgroud)
?
我也试过这个:
-- file: ch03/BogusPattern.hs
data Fruit = Apple | Orange
deriving (Show)
apple = "f1"
orange = "f2"
whichFruit :: String -> Fruit
whichFruit f = case f of
"f1" -> Apple
"f2" -> Orange
Run Code Online (Sandbox Code Playgroud)
它不起作用.
Ghci说f1 …
q3 a (b:[]) = a b
q3 a (b1:b2:bs) = q3 a (b2:bs)
Run Code Online (Sandbox Code Playgroud)
似乎a对功能没有任何影响.我的理解是这个函数有两个参数,第二个是列表,并返回第一个参数和第二个列表的尾部.但是,我对类型感到困惑:
q3 :: (t1 -> t) -> [t1] -> t
Run Code Online (Sandbox Code Playgroud)
怎么a相关t1 -> t?谢谢.
haskell ×9
ghci ×2
c++ ×1
combinators ×1
dot-operator ×1
fold ×1
g++ ×1
gcc ×1
java ×1
openmp ×1
pointfree ×1
react-router ×1
stanford-nlp ×1
typescript ×1