“继承”包装类型的实例(“Inheriting” instance of wrapped type)
我有一个类型,基本上作为另一种数据类型的标签:
import Data.Word data RijndaelField = RF Word8
我希望
RijndaelField
以最简单的方式“继承”Bits
的Word8
实例:import Data.Bits instance Bits RijndaelField where RF a .&. RF b = RF $ a .&. b RF a .|. RF b = RF $ a .|. b RF a `xor` RF b = RF $ a `xor` b complement (RF a) = RF $ complement a shift (RF a) n = RF $ shift a n rotate (RF a) n = RF $ rotate a n bitSize (RF a) = bitSize a isSigned (RF a) = isSigned a testBit (RF a) n = testBit a n bit n = RF $ bit n popCount (RF a) = popCount a
有没有更简单的方式来表达
RijndaelField
和Word8
之间的关系?I have a type that basically acts as a tag on another data type:
import Data.Word data RijndaelField = RF Word8
I want
RijndaelField
to "inherit" theWord8
instance ofBits
in the simplest way possible:import Data.Bits instance Bits RijndaelField where RF a .&. RF b = RF $ a .&. b RF a .|. RF b = RF $ a .|. b RF a `xor` RF b = RF $ a `xor` b complement (RF a) = RF $ complement a shift (RF a) n = RF $ shift a n rotate (RF a) n = RF $ rotate a n bitSize (RF a) = bitSize a isSigned (RF a) = isSigned a testBit (RF a) n = testBit a n bit n = RF $ bit n popCount (RF a) = popCount a
Is there a shorter way to express that relation between
RijndaelField
andWord8
?
原文:https://stackoverflow.com/questions/20481718
最满意答案
限制取决于
GROUP_CONCAT()
的结果。 你可以改变它:SET group_concat_max_len = 10000
SET GLOBAL group_concat_max_len = (7*1024); SET GLOBAL max_allowed_packet = (50*1024*1024);
The root of the problem was the function GROUP_CONCAT. the documentation says GROUP_CONCAT's
group_concat_max_len
IS LIMITED BYmax_allowed_packet
: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat50% to @echo_me and 50% to @barmar. It has to be done together, otherwise it wont work.
Full code:
SET GLOBAL group_concat_max_len = (7*1024); SET GLOBAL max_allowed_packet = (50*1024*1024); SET @src = 'Test'; SET @tgt = 'Test2'; SET @db = 'Test'; SET @pk = 'ID, MyPk, etc'; SELECT CONCAT( @pk, GROUP_CONCAT(CONCAT( ", ", COLUMN_NAME) SEPARATOR "") ) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = @db AND TABLE_NAME = @src INTO @cols;
相关问答
更多-
限制取决于GROUP_CONCAT()的结果。 你可以改变它: SET group_concat_max_len = 10000 SET GLOBAL group_concat_max_len = (7*1024); SET GLOBAL max_allowed_packet = (50*1024*1024); The root of the problem was the function GROUP_CONCAT. the documentation says GROUP_CONCAT's grou ...
-
\[(=*)\[.*?\]\1\] \ 1捕获第一个()。 \[(=*)\[.*?\]\1\] the \1 captures the first ().
-
一个选项: 将所有可能的字符放在只有一列的表中。 val ------ 0 1 ... 9 a b ... z 使用此查询 SELECT CONCAT(a.val,b.val,c.val,d.val) FROM chars AS a JOIN chars AS b JOIN chars AS c JOIN chars AS d ORDER BY RAND() LIMIT 10000 另一方面,如果你需要一次获得一个ID,我会看到两种方法。 答:如果您有许多未分配的ID可用。 在这种情况下,您只需生成一个 ...
-
有,如果您阅读格式说明符的手册页。 你可以用*替换精度,这意味着它将从一个参数取而代之。 int numDigits = 10; NSString *value = [NSString stringWithFormat:@"%.*Lg", numDigits, valueX]; 我在核心基础参考中找不到这个,但我知道这是写在man 3 printf手册页中的。 There is, if you read the manual pages for format specifiers. You can rep ...
-
更简洁的方法是使用字典: COLUMN_VARIABLES = ['provider', 'language','subtype'] data = {} for variable in COLUMN_VARIABLES: data[variable] = node.xpath("//%s/text()"%variable)[0] 专业提示:每当你发现自己想要使用变量变量名时,就意味着你不需要变量,你希望一个容器代替所有数据。 The more concise way to do this wo ...
-
在C ++中,没有long long数据类型。 它在C99中可用 。 但是,您可以使用int64_t 。 包括
。 使用boost::lexical_cast将字符串转换为int64_t 。 或者您可以自己编写转换函数: int64_t convert(const std::string &s) { if(s.size() == 0 ) std::runtime_error error("invalid argument"); int64_t v = 0; ... -
只是用 query_state = mysql_query(connection, sql.c_str()); 从std :: string到const char *没有隐式转换。 Just use query_state = mysql_query(connection, sql.c_str()); There is no implicit cast from std::string to const char*.
-
从(String)获取(长,字符串)=>尝试[(长,字符串)](Getting (Long, String) from (String) => Try[(Long, String)])[2023-05-09]
有几种选择 val exceptional: Try[(Long, String)] = ??? val default: (Long, String) = (0, "") 提供后备价值 exceptional.getOrElse(default) 处理异常然后安全地get exceptional.recover { case exception => default }.get 或使用模式匹配 exceptional match { case Success(v) => v case Fai ... -
如何获取当前保留的变量类型,并定义该类型的新变量(How to get currently held variant type, and define new variables of that type)[2023-10-16]
您可以使用带有调用操作符模板的访问者仿函数来执行此类操作: struct MyVisitor : public boost::static_visitor<> { templatevoid operator()(const StorageT&) const { StorageT new_val = 32; // declare variable with same type doSomethingWith(n ... -
查询(假设time是可以排序的datetime time列): SELECT * FROM `noblemappack` ORDER BY `time` DESC LIMIT 6 如果您没有可以排序的日期时间字段,请添加一个。 “最后6”是非常模糊的。 如果你只是将结果放在一个数组中,那么你就完全了。 您不应该将值保留在单个变量中,将它们保存为数组中的数据集更容易使用。 array( array('value' => 'foo', 'time' => '13:45', 'date' => '201 ...