小编Bri*_*Yeh的帖子

导入haskell模块说"不在范围内"

我在名为Tree2.hs的文件中创建了一个Tree结构

module Tree2
(
 Tree
) where

data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show)
Run Code Online (Sandbox Code Playgroud)

然后我导入它并尝试将其用作类的实例

import qualified Tree2

class YesNo a where
  yesno :: a -> Bool

instance YesNo (Tree2.Tree a) where
  yesno EmptyTree = False
  yesno _ = True
Run Code Online (Sandbox Code Playgroud)

但是我在ghci中加载时遇到此错误:

Not in scope: data constructor ‘EmptyTree’
Failed, modules loaded: Tree2.
Run Code Online (Sandbox Code Playgroud)

谁知道为什么?

haskell class instance

2
推荐指数
1
解决办法
923
查看次数

nppi 调整大小功能,3 个通道得到奇怪的输出

使用 nppi cuda 库中的 nppi 几何变换函数时,出现奇怪的错误。代码在这里:

#include <nppi.h>
#include <nppi_geometry_transforms.h>

#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <vector>

void write(const cv::Mat &mat1, const std::string &path) {
    auto mat2 = cv::Mat(mat1.rows, mat1.cols, CV_8UC4);
    for (int i = 0; i < mat1.rows; i++) {
        for (int j = 0; j < mat1.cols; j++) {
            auto &bgra = mat2.at<cv::Vec4b>(i, j);
            auto &rgb = mat1.at<cv::Vec3b>(i, j);
            bgra[0] = rgb[2];
            bgra[1] = rgb[1];
            bgra[2] = rgb[0];
            bgra[3] = UCHAR_MAX;
        }
    }
    std::vector<int> compression_params; …
Run Code Online (Sandbox Code Playgroud)

c++ opencv cuda nvidia

2
推荐指数
1
解决办法
306
查看次数

glCreateShader在OSX上抛出异常,为什么?

我有一些代码,我直接按照教程生成一个三角形.作者在windows中编写代码,但他说这也可以在OSX中完成.我能够让程序编译,但是当它击中glCreateShader时会抛出异常.我到处都看,但我无法弄清楚出了什么问题.这肯定是一些新手的错误.有谁知道什么可能是错的?

#include <iostream>
#include <string>
#include <Dunjun/Common.hpp>
#include <GL/glew.h>
#include <OpenGL/glext.h>
#include <OpenGL/gl.h>
#include <GLFW/glfw3.h>

#define GLOBAL static
#define internal static
#define LOCAL_PERSIST static

#define float32 float
#define float64 double

GLOBAL const int g_windowWidth = 854;
GLOBAL const int g_windowHeight = 480;
GLOBAL const char* g_gameTitle = "Dunjun";

GLFWwindow *toggleFullScreenWindow(GLFWwindow *window, int key);

void setColor(float32 red, float32 blue, float32 green, float32 alpha);

bool toggleExit(GLFWwindow *window, bool isRunning);

GLFWwindow* initialize_window(int width, int height, const char* title);

void init_glfw();

void init_glew();

void …
Run Code Online (Sandbox Code Playgroud)

c++ opengl macos

1
推荐指数
1
解决办法
523
查看次数

在Golang中解组json

golang初学者在这里。

我想解组此处显示的一些JSON:

 {
  "intro": {
    "title": "The Little Blue Gopher",
    "story": [
      "Once upon a time, long long ago, there was a little blue gopher. Our little blue friend wanted to go on an adventure, but he wasn't sure where to go. Will you go on an adventure with him?",
      "One of his friends once recommended going to New York to make friends at this mysterious thing called \"GothamGo\". It is supposed to be a big event with free swag …
Run Code Online (Sandbox Code Playgroud)

json go unmarshalling

-1
推荐指数
1
解决办法
145
查看次数

标签 统计

c++ ×2

class ×1

cuda ×1

go ×1

haskell ×1

instance ×1

json ×1

macos ×1

nvidia ×1

opencv ×1

opengl ×1

unmarshalling ×1