小编mil*_*ose的帖子

Haskell - where子句中的函数有一个`Integer`推断参数,但总是用`Int`调用

我的赋值问题是找到字符串中子字符串的所有非重叠出现,并返回找到的出现的起始索引列表.

到目前为止我的代码是:

-- return True when `e` (haystack) starts with `s` (needle)
_startsWith :: String -> String -> Bool
-- Anything starts with the empty string
_startsWith _ "" = True
-- An empty string cannot start with a nonempty string 
_startsWith "" (h:t) = False 
_startsWith (eh:et) (sh:st) = (eh==sh) && (_startsWith et st)

-- look for all occurences of `s` (needle) in `e` (haystack), accumulating 
-- start indices of occurences in `is`
_findAll :: [Integer] -> Integer -> …
Run Code Online (Sandbox Code Playgroud)

haskell type-inference

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

"'NoneType'对象不可迭代"错误

刚刚写了我的第一个python程序!我在邮件中将zip文件作为附件保存在本地文件夹中.该程序检查是否有任何新文件,如果有的话,它会提取zip文件,并根据文件名提取到不同的文件夹.当我运行我的代码时,我收到以下错误:

回溯(最近调用最后一次):文件"C:/Zip/zipauto.py",第28行,用于new_files中的文件:TypeError:'NoneType'对象不可迭代

任何人都可以告诉我哪里出错了.

非常感谢你的时间,

Navin这是我的代码:

import zipfile
import os

ROOT_DIR = 'C://Zip//Zipped//'
destinationPath1 = "C://Zip//Extracted1//"
destinationPath2 = "C://Zip//Extracted2//"

def check_for_new_files(path=ROOT_DIR):

    new_files=[]
    for file in os.listdir(path):
        print "New file found ... ", file

def process_file(file):

    sourceZip = zipfile.ZipFile(file, 'r')
    for filename in sourceZip.namelist():
            if filename.startswith("xx") and filename.endswith(".csv"):
                    sourceZip.extract(filename, destinationPath1)
            elif filename.startswith("yy") and filename.endswith(".csv"):
                    sourceZip.extract(filename, destinationPath2)
                    sourceZip.close()

if __name__=="__main__":
    while True:
            new_files=check_for_new_files(ROOT_DIR)
            for file in new_files: # fails here
                    print "Unzipping files ... ", file
                    process_file(ROOT_DIR+"/"+file)
Run Code Online (Sandbox Code Playgroud)

python

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

优化使函数立即返回而不是执行

我正在研究VS 2010 express并尝试进行一些文件读取和解析工作

我的功能是这样的......(我丢掉了无聊的部分)

void SomeClass::SomeFunc(char *ALName, std::map<...> *chromList, std::map<...> *chromLine)
{
    ifstream file;
    char tmpBuff[500];
    char tmpBuff2[500];
    char fileName[350];
    char tmp[350];
    char *pch;
    char *pch2;

    .....

    file.open(fileName);

    while ( file.getline( tmpBuff, 500 ) ) 
    {
        ....
        if ( some_condition == 0 )
        {
          pch2 = strtok( NULL, "," );
          pch = strtok( NULL, "," );
          (*chromList)[pch2] = do_some_work( atoi(pch), tmpBuff2 );
          strcpy( tmp, get_chrom_line( tmpBuff2 ) );
          (*chromLine)[pch2] = tmp;
        }
    }

    file.close();

 }
Run Code Online (Sandbox Code Playgroud)

当我更改为Release with Optimization设置为Maximum speed时,将跳过此功能.调试器进入该函数并立即返回.

当我运行Debug设置或Release并将Optimization标志设置为disabled时,该函数运行正常. …

c c++ optimization release visual-studio-2010

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

GetLength()方法在数组上无法正常工作

这是一个C#代码.

它输出以下文字:

tab.Length = 6
tab.Rank = 2
Length of dim 0 of tab : 0
Length of dim 1 of tab : 1
Run Code Online (Sandbox Code Playgroud)

我期待以下文字:

tab.Length = 6
tab.Rank = 2
Length of dim 0 of tab : 2
Length of dim 1 of tab : 3
Run Code Online (Sandbox Code Playgroud)

为什么不?谢谢.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TableTest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] tab = new int[2, 3];

            for (int i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

c#

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

下载Java类文件和运行?

好的,我正在尝试为我的Java类文件添加安全性.我不希望它被反编译.所以我所做的就是创建一个登录系统,java应用程序通过Web请求对其进行检查.如果登录信息正确,那么它将运行脚本.但是,我想进一步提高安全性并在线托管类文件.

如何下载并运行在线托管文件?

此外,当app /脚本停止运行或关闭时,将删除.class文件.

我更喜欢它没有下载文件的地方,只需从在线服务器获取并编译/运行.

java

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

不明白错误消息

public class ArrayPrac {

    public static void main(String[] args) {
        int[] arrayOne = {2, 3, 4, 5, 6};
        System.out.println(findMin(arrayOne));
    }

    public static void findMin(int[] list) {
        int minValue = list[0];
        int i = 1;      
        for( i = 1; 1 < list.length; i++);
            if(list[i] < minValue) {
                minValue = list[i];

            }
    }     
}
Run Code Online (Sandbox Code Playgroud)

在第6行的System.out.print部分,它不会运行并给我编译器错误:

PrintStream类型中的println(boolean)方法不适用于参数(void)

我似乎整天都在寻找答案,所以现在我发布我的具体案例.

干杯.

java arrays boolean void

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

如何制作一个wicket组件,在每个AJAX请求重新呈现到页面?

有没有办法让Wicket组件在每个页面的AJAX请求上重新呈现?(基本上ajaxRendered="true"是在RichFaces中做什么.)

我的申请基本上包括以下内容:

  • 可编辑的数据网格记录用户正在进行的更改
  • 这些更改存储在会话中
  • 有按钮可以保存更改或撤消更改.

应启用或禁用保存和撤消按钮,具体取决于是否有任何记录的更改.由于有多种方法可以输入更改(编辑,导入CSV等),因此我希望避免拦截可能会更改已保存状态的每个操作.

此外,按钮仅显示在某些页面上,因此我不想在自定义中在页面中嗅探它们WebRequestCycle.

当一个AJAX请求即将被处理时,是否有一个Wicket调用的钩子,这是为页面上的每个组件调用的?我知道有Component#onBeforeRender()Component#onConfigure(),但对他们的文档时,他们呼吁AJAX请求并不状态.

java ajax wicket

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

切换/选择语句:是否可以跳转到不同的case子句?

说我在VB.NET中有这个:

Dim executeB As Boolean
Select Case myVariable
  Case "a"
    'some code
  Case "b"
     'some code
  Case Else
End Select
Run Code Online (Sandbox Code Playgroud)

如果myVariable是"a",则控件将进入第一个case语句.现在让我们说如果myVariable ="a",但是在一个case块中,我发现executeB是真的,那么它是否可以跳转到第二种情况?

.net vb.net

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

将英国日期时间转换为美国日期时间

我的Windows XP计算机上的当前区域设置是英语(英国).使用我的C#app,如何将DateTime值为31/05/2012 的对象转换为US DateTime对象,即.收取罚金?这可能没有设置Thread.CurrentThread.CurrentCulture吗?

谢谢.

c# datetime

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

如何根据主查询计算表中的项?

好吧,伙计们说我正在做这个查询:

SELECT `category_id`, `category_name` 
FROM `database_categorys` 
ORDER BY `category_name` ASC
Run Code Online (Sandbox Code Playgroud)

现在我想计算名为"database_items"的表中的所有行,其中item表的类别id等于当前行类别id.

我正在猜测某种连接或嵌套查询,但我不能用正确的语法来解决这个问题.

因此,当它回应时,我可以这样做:

<category name> <total items in category number>
Run Code Online (Sandbox Code Playgroud)

php mysql pdo

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