小编And*_*eas的帖子

Java改变系统的新行字符

在Windows上,在Unix系统上使用System.out.println()打印输出.\n\r\n

有没有办法告诉java你想要使用哪些换行符?

java unix windows newline text-formatting

5
推荐指数
2
解决办法
5966
查看次数

哈斯克尔:'做[1,2,3]; ["你好"]'行为澄清

所以我试图准确理解Haskell do符号是如何工作的.据我所知,它与monad一起使用,它基本上扩展(因为它实际上是语法糖)到与bind(>>=)或then(>>)连接的匿名函数,如下所示https://en.wikibooks.org/wiki/Haskell/Syntactic_sugar #Do_notation.

但是我的问题是为什么以下命令

Prelude> do [1, 2, 3]; "hello"
Run Code Online (Sandbox Code Playgroud)

回报

"hellohellohello"
Run Code Online (Sandbox Code Playgroud)

我知道数组实际上是monad(并且这些字符串是字符数组)但是我没有看到它如何导致上面的行为.

monads haskell do-notation

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

C#Dictionary无法找到字符串键

我疯了吗?为什么这会返回异常!?为什么找不到钥匙?它显然在那里!

public class Spanning {
    Dictionary<string, City> graph = new Dictionary<string, City>();

    public static void Main(string[] args) {
        new Spanning().Parse("file.in");
    }

    public void Parse(string f) {
        string[] citySeparator = new string[] {"--"};
        using (StreamReader reader = new StreamReader(f)) {
            string line;
            while((line = reader.ReadLine()) != null) {
                if (!line.Contains("--")) {
                    graph[line] = new City {name = line.Substring(0, line.Length - 1)};
                } else {
                    string[] split = line.Split(citySeparator, StringSplitOptions.None);
                    City city1 = graph[split[0]];
                }
            }
        }
    }

    class City {
        Dictionary<City, …
Run Code Online (Sandbox Code Playgroud)

c# string parsing dictionary

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