在我的GHC Haskell应用程序中使用stm,network-conduit和conduit,我为每个socket自动分叉使用了一个strand runTCPServer.Strands可以通过使用广播TChan与其他线路进行通信.
这展示了我想如何建立管道"链":

所以,我们这里有两个源(每个都绑定到辅助管道),它们产生一个接受并转入的Packet对象,然后发出套接字.对于两个输入的有效(性能是一个问题),我遇到了很大的困难.encoderByteString
如果有人能指出我正确的方向,我将不胜感激.
既然我没有尝试就发布这个问题是不礼貌的,我会把我以前在这里尝试过的东西放进去;
我已经编写/编写了一个函数,它(阻塞)从TMChan(可关闭的通道)生成一个源;
-- | Takes a generic type of STM chan and, given read and close functionality,
-- returns a conduit 'Source' which consumes the elements of the channel.
chanSource
:: (MonadIO m, MonadSTM m)
=> a -- ^ The channel
-> (a -> STM (Maybe b)) -- ^ The read function
-> (a -> STM ()) -- ^ The close/finalizer function
-> Source m b
chanSource …Run Code Online (Sandbox Code Playgroud) 是否有一个命令行工具,我可以使用(或附带)Visual Studio,它将以简单易于解析的格式打印C++静态lib文件中的符号名称?
请考虑以下代码:http://hpaste.org/90394
我将内存映射到一个大的460mb文件到一个懒惰的ByteString.ByteString报告的长度471053056.
何时nxNodeFromID file 110000更改为较低的节点ID,即:10000,它完美地工作.然而; 一旦我尝试序列化任何过去正好2 ^ 18字节(262144)的ByteString,我得到Segmentation fault/access violation in generated code并终止.
我正在运行Windows并使用GHC 7.4.2.
请告知这是我的错,还是懒惰的问题,或Haskell的一些问题.
我从DirectX获取了存储顶点信息的存储位置.处理顶点信息的一种非常方便的方法是使用包含顶点信息的结构的std :: vector <>.
鉴于我有一个指向大缓冲区的指针,我可以使用std :: vector来管理缓冲区中的元素吗?经常构造一个std :: vector使它有自己的地址,这不是我想要的.我可以以某种方式使用操作员放置吗?
asio库在很多例子中都传递了一个错误参数,即; http://think-async.com/Asio/asio-1.5.3/src/examples/echo/async_tcp_echo_server.cpp
这个参数有什么意义?asio实际上是否填充了此参数的错误?
如果我从处理程序函数中删除它,它编译得很好.
考虑以下功能median:
real_t median(const std::initializer_list<real_t> vars) {
real_t tmp[15];
const unsigned x = vars.size() / 2;
if (x & 1) {
std::partial_sort_copy(vars.begin(), vars.end(), &tmp[0], &tmp[x]);
return tmp[x];
}
const unsigned y = x + 1;
std::partial_sort_copy(vars.begin(), vars.end(), &tmp[0], &tmp[y]);
return (tmp[x] + tmp[y]) / 2;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用部分排序来降低复杂性,因为我只需要对列表的一半进行排序.
此外,我假设std::partial_sort_copy比排序算法(It1!= It2)更快std::partial_sort或者std::nth_element因为没有需要改组.我的假设是否正确?
注意:假设real_t可能是a double,所以请不要批评使用除法.
NBB:我正在使用-pedantic并且vars已知不超过15个元素.
我已经编写了这个Haskell程序来解决Euler 15(它使用一些非常简单的动态编程来运行得更快,所以我实际上可以运行它,但删除你期望它运行的O(2^n).
-- Starting in the top left corner of a 2×2 grid, and only being able to move to
-- the right and down, there are exactly 6 routes to the bottom right corner.
--
-- How many such routes are there through a 20×20 grid?
calcPaths :: Int -> Integer
calcPaths s
= let go x y
| x == 0 || y == 0 = 1
| x == y = 2 * go x …Run Code Online (Sandbox Code Playgroud) algorithm haskell mathematical-optimization dynamic-programming compiler-optimization
我在gcc下使用默认的C语言.
我的代码:
typedef struct _OpcodeEntry OpcodeEntry;
Run Code Online (Sandbox Code Playgroud)
//
struct _OpcodeEntry
{
unsigned char uOpcode;
OpcodeMetadata pMetadata;
};
Run Code Online (Sandbox Code Playgroud)
//
const OpcodeMetadata omCopyBytes1 = { 1, 1, 0, 0, 0, 0, &CopyBytes };
const OpcodeEntry pOpcodeTable[] =
{
{ 0x0, omCopyBytes1 },
};
Run Code Online (Sandbox Code Playgroud)
错误:
error: initializer element is not constant
error: (near initialization for 'pOpcodeTable[0].pMetadata')
Run Code Online (Sandbox Code Playgroud)
如果我更改omCopyBytes1为上面一行中实际设置的内容,则代码编译正常.我究竟做错了什么?
请考虑以下示例:
instance (Monad m) => MonadState s (ChronoT s e m) where
-- | Returns the present-day state.
get = ChronoT $ do
(ChronoS _ s _) <- get
return s
-- | Set the present-day state directly, erasing the past and future for
-- safety. See also 'paradox'.
put x = ChronoT $ do
(ChronoS _ _ _) <- get
put $ mkChronoS x
Run Code Online (Sandbox Code Playgroud)
当通过黑线鳕运行,功能get和put显示出来,但他们使用的是从MonadState默认文档.如何在我的模块中包含我自己的文档?
(你可以cabal haddock在这里看看我的意思,看看我的意思)
我已经反向设计了跟随算法来生成随机数;
int __cdecl sub_40BB60()
{
char v0; // si@1
int v1; // edx@1
int v2; // ecx@1
unsigned int v3; // eax@1
int v4; // edi@1
int v5; // esi@1
int result; // eax@1
v0 = random_state;
v1 = dword_685440[((_BYTE)random_state - 3) & 0xF];
v2 = dword_685440[random_state] ^ v1 ^ ((v1 ^ 2 * dword_685440[random_state]) << 15);
v3 = ((unsigned int)dword_685440[((_BYTE)random_state - 7) & 0xF] >> 11) ^ dword_685440[((_BYTE)random_state - 7) & 0xF];
v4 = v3 ^ dword_685440[random_state] ^ v1 …Run Code Online (Sandbox Code Playgroud)