小编jos*_*shj的帖子

使用镜头有哪些优缺点?

镜头似乎没有任何缺点,同时具有优于标准Haskell的显着优势:是否有任何理由我不应该尽可能使用镜头?有性能考虑吗?另外,模板Haskell是否有任何重大开销?

haskell lenses

25
推荐指数
2
解决办法
3259
查看次数

使用mingw安装任何内容时,使用Python 3.x的Pip或easy_install会爆炸

我有vcvarsall.bat问题,所以我按照这里的说明如何在使用Pip安装Python包时使用MinGW的gcc编译器?.

现在,pip install lxml在Windows 7上使用Python 3.2.2时,我收到以下错误:

C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python32\include -IC:\Pytho
n32\PC -c src/lxml/lxml.etree.c -o build\temp.win32-3.2\Release\src\lxml\lxml.et
ree.o -w

cc1.exe: error: unrecognized command line option '-mno-cygwin'

error: command 'gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

整个输出:

C:\Python32\Scripts>pip-3.2.exe install lxml
Downloading/unpacking lxml
  Real name of requirement lxml is lxml
  Downloading lxml-2.3.3.tar.gz (3.1Mb): 3.1Mb downloaded
  Running setup.py egg_info for package lxml
    Building lxml version 2.3.3.
    Building without Cython.
    ERROR: b"'xslt-config' is not recognized as an internal or external …
Run Code Online (Sandbox Code Playgroud)

python pip easy-install python-3.x

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

为什么这样做?这是一个小例子,但它甚至可以用于更复杂的项目

#include <cstdio>
class baseclass
{
};

class derclass : public baseclass
{
public:
    derclass(char* str)
    {
        mystr = str;
    }
    char* mystr;
};
baseclass* basec;

static void dostuff()
{
    basec = (baseclass*)&derclass("wtf");
}

int main()
{
    dostuff();
__asm // Added this after the answer found, it makes it fail
{
    push 1
    push 1
    push 1
    push 1
    push 1
    push 1
    push 1
    push 1
    push 1
    push 1
}
    printf("%s", ((derclass*)basec)->mystr);
}
Run Code Online (Sandbox Code Playgroud)

c++

3
推荐指数
2
解决办法
264
查看次数

有人可以修复以下Data.Binary示例代码吗?

试图学习如何使用Data.Binary并在此处遇到障碍:

http://www.haskell.org/haskellwiki/Serialisation_and_compression_with_Data_Binary

D:\Projects\haskell\serialize\ex1.hs:114:26:
    Couldn't match expected type `bytestring-0.9.1.10:Data.ByteString.Lazy.Internal.ByteString'
                with actual type `L.ByteString'
    Expected type: Int
                   -> bytestring-0.9.1.10:Data.ByteString.Lazy.Internal.ByteString
      Actual type: Int -> L.ByteString
    In the return type of a call of `toByteString'
    In the second argument of `(.)', namely `toByteString f'

D:\Projects\haskell\serialize\ex1.hs:122:21:
    Couldn't match expected type `L.ByteString'
                with actual type `bytestring-0.9.1.10:Data.ByteString.Lazy.Internal.ByteString'
    In the first argument of `L.length', namely `fs'
    In the first argument of `(+)', namely `L.length fs'
    In the first argument of `(==)', namely `L.length fs + L.length is'
[Finished]
Run Code Online (Sandbox Code Playgroud)

haskell

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

如何找到循环所需的乘数?

#include <iostream>
using namespace std;
int main() {

  float result = 50.0f;
  float multiplier = 0.5f;
  float fixed_multiplier = 1.0f - multiplier * 0.001f;
  for (int i = 0; i < 1000; ++i) {
    result *= fixed_multiplier;
  }

  cout << result << endl; // 30.322 -- want approximately 25
}
Run Code Online (Sandbox Code Playgroud)

在1000次迭代之后,我想result等于multiplier*result(result==25).如何找到修改乘数(in fixed_multiplier)以获得所需结果所需的内容?

c++ math

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

需要帮助将迭代模式转换为公式

var = 8

itr 1:
var == 8 (8 * 1)

itr 2:
var == 24 (8 * 3)

itr 3:
var == 48 (8 * 6)

itr 4:
var == 80 (8 * 10)

itr 5:
var == 120 (8 * 15)
Run Code Online (Sandbox Code Playgroud)

模式:( var*(最后乘数+当前迭代))

基本上我想得到公式(itr)的结果,而不必迭代到itr.

iteration math recursion analytical

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