小编Sar*_*yan的帖子

Haskell:'do'结构中的最后一个语句必须是一个表达式

嘿,很抱歉在这里转发错误信息,但我已经尝试了所有我能找到的东西,似乎没什么关系.此代码生成错误:

import System.Environment   
import System.Directory  
import System.IO  
import Data.List  

data Node = PathNode String Float Float [String] | NoNode deriving (Show)


main = do
    (filename:args) <- getArgs  
    load filename


load :: String -> IO ()  
load fileName = do
    contents <- readFile fileName  
    let pathStrings = lines contents
        first = head pathStrings
        args = lines first
        path = createNode args
        putStr path


createNode [String] -> Node
createNode (name:x:y:paths) = PathNode name x y paths
createNode [] = NoNode
Run Code Online (Sandbox Code Playgroud)

我知道它与对齐有关,但我已正确对齐'load'函数中的所有调用.我究竟做错了什么?

谢谢

io syntax monads haskell

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

lual_dofile(); 不会用C++和Lua加载脚本

您好我正在尝试使此代码正常工作

extern "C"
{
#include <lua.h>
#include "lualib.h"
#include "lauxlib.h"
}

#include "glew.h"
#define GLEW_STATIC
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <stdlib.h>
#include <iostream>
#include <fstream>




////////////////////////
////////////////////////
test.h
void Test(void)

{
    int status;

**//The Lua Interpreter**
lua_State  *L = lua_open();


**//Open Lua Libarys**
luaL_openlibs(L);



**//Run Lua Script**
status = luaL_loadfile(L,"Test.lua");

printf( "actually getting to this point!");
getchar();
//Close Lua
lua_close(L);



}
Run Code Online (Sandbox Code Playgroud)

这个名字叫test.lua这是我的lua文件

print"Whats your name?"

function sleep(n)
end
Run Code Online (Sandbox Code Playgroud)

这不起作用:(

lual_dofile(L, "Test.lua");

孔程序编译,但然后不执行脚本或显示运行的lua脚本的任何视觉反馈有没有人遇到此问题之前?并且知道为什么?**

c++ lua file

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

根据空格或"双引号字符串"将字符串解析为数组

我试图取一个用户输入字符串并解析为一个名为char*entire_line [100]的数组; 其中每个单词放在数组的不同索引处,但如果字符串的一部分由引号封装,则应将其放在单个索引中.所以,如果我有

char buffer[1024]={0,};
fgets(buffer, 1024, stdin);
Run Code Online (Sandbox Code Playgroud)

示例输入:"word filename.txt"这是一个字符串,shoudl占用输出数组中的一个索引";

tokenizer=strtok(buffer," ");//break up by spaces
        do{
            if(strchr(tokenizer,'"')){//check is a word starts with a "
            is_string=YES;
            entire_line[i]=tokenizer;// if so, put that word into current index
            tokenizer=strtok(NULL,"\""); //should get rest of string until end "
            strcat(entire_line[i],tokenizer); //append the two together, ill take care of the missing space once i figure out this issue

              }  
        entire_line[i]=tokenizer;
        i++;
        }while((tokenizer=strtok(NULL," \n"))!=NULL);
Run Code Online (Sandbox Code Playgroud)

这显然是行不通的,只有当双引号封装的字符串是输入字符串的结束,但我可以有输入靠拢:单词"这是文本,这将是用户输入" FILENAME.TXT一直试图弄清楚这一点有一段时间,总是卡在某个地方.谢谢

c parsing split strtok

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

执行 while 条件 vb6

我有一个vb6小程序:

Private Sub Form_Load()
    Dim varTemp As Variant
    Dim string1 As String

    Dim x As Integer
    x = 0

    dialog.Filter = "toate fisierele(*.*) | *.*"
    dialog.Flags = cdlOFNAllowMultiselect Or cdlOFNLongNames Or cdlOFNExplorer

    'open the window to select files
    dialog.ShowOpen

    varTemp = Split(dialog.FileName, vbNullChar)

    Do While (varTemp(x) <> "")

    string1 = varTemp(x)
    x = x + 1

    Loop

    Unload Form1
    End

End Sub
Run Code Online (Sandbox Code Playgroud)

我希望 Do While 循环,直到到达 varTemp 的末尾。但是,当我从对话框中选择两个文件并且使用 x = 3 命中“Do While”时,我收到“运行时错误‘9’:下标超出范围”。“Do While”循环必须在什么条件下循环直到 varTemp 结束?谢谢。

vb6 while-loop

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

做块的条件

为什么以下代码块:

main = do
    line <- getLine
    if null line
        then runTestTT tests
        else do
            line2 <- getLine
            seq::[Int] <- return $ map read $ words line2
            print $ process seq
Run Code Online (Sandbox Code Playgroud)

抛出错误:

lgis.hs:28:13:
    Couldn't match type `()' with `Counts'
    Expected type: IO Counts
      Actual type: IO ()
    In a stmt of a 'do' block: print $ process seq
    In the expression:
      do { line2 <- getLine;
           seq :: [Int] <- return $ map read $ words line2;
           print $ process …
Run Code Online (Sandbox Code Playgroud)

io haskell

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

虽然声明不起作用C.

我正在学习C,而我正在尝试制作一个基本的计算器,但是在使用while语句时遇到了一些麻烦.我尝试过多种方式,但它从不重复,只需完成脚本.

有任何想法吗?

//
//  main.c
//  Calculator
//
//  Created by Austen Patterson on 2013-06-27.
//  Copyright (c) 2013 Austen Patterson. All rights reserved.
//

#include <stdio.h>
#include <stdbool.h>

int main()
{
    int number[100];
    int operator = '0';
    int doAgainAnswer = '0';
    bool doAgain;
    do{ 
    printf("Please enter your first number:");
    scanf("%d", &number[1]);
    printf("\nYou entered %d as your first number. Please enter your second: ", number[1]);
    scanf("%d", &number[2]);
    printf("\nYou entered %d as your second number.", number[2]);
    printf("\nYour numbers are now %d …
Run Code Online (Sandbox Code Playgroud)

c while-loop do-while

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

如何自定义搜索栏的拇指

我想显示一个TextView上方的拇指SeekBar,它将显示搜索栏的当前进度.当我们向前和向后TextView移动拇指时,拇指也会移动(TextView也应该在拇指上方).

请提供任何线索,始终欢迎代码段.

android seekbar

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

循环开始停止时C#做

我试图为这个循环制作一个停止按钮,但它运行无限期,当我点击按钮2时没有任何反应

bool dowhile = false;
private void button1_Click(object sender, EventArgs e)
{
    do
    {
        for (int i = listbox1.Items.Count - 1; i >= 0; i--)
        {
            string textstring = listbox1.Items[i].ToString();
            richTextBox1.AppendText("" + textstring + ": Done\n");
            Thread.Sleep(1000);
        }
    } while (!dowhile);
}
private void button2_Click(object sender, EventArgs e)
{
    this.dowhile = true;
}
Run Code Online (Sandbox Code Playgroud)

我哪里出错了?

sry for"lvlchanger"错字,现在代码还可以,没有什么遗漏

我也在寻找一个不那么长的修复:))

c# loops for-loop while-loop do-while

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

Perl中的"do"函数

最近,我有一个perl脚本,使用"do"调用另一个perl脚本; 即.

do "./script2.pl $arg1 $arg2";

我的script2.pl被设计为使用2个参数.

但是,以上述方式调用script2.pl不会将参数传递给script2.pl.

我知道有另一种方法使用"system",但我的script1.pl需要通过"require"获取一些变量值.

我可以实际使用"do"并将参数传递给我的script2吗?

perl

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

如何在Android中将自定义类List的属性绑定到Spinner?

我正在从托管的移动服务客户端检索自定义对象列表Azure Cloud,现在我想此类的一个属性绑定到客户端中的Spinner控件Android.

正如下面我的代码,我有一个List<Departement>从Azure的移动服务来了,我要绑定DepartmentName的这个Spinner在Android客户端.

public class Department
{
    public int ID;
    public String DepartmentName;
}
Run Code Online (Sandbox Code Playgroud)

任何建议都非常感谢

android list spinner android-spinner

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

标签 统计

while-loop ×3

android ×2

c ×2

do-while ×2

haskell ×2

io ×2

android-spinner ×1

c# ×1

c++ ×1

file ×1

for-loop ×1

list ×1

loops ×1

lua ×1

monads ×1

parsing ×1

perl ×1

seekbar ×1

spinner ×1

split ×1

strtok ×1

syntax ×1

vb6 ×1