小编Tha*_*los的帖子

我在列表理解方面遇到了困难

我真的想要一个简单的解释.我有一大堆函数,其中一个列表推导表现得非常奇怪.

sequence_ [writeArray arr (x, y) a | x <- xs, a <- as]
    where xs = [1,3,2]
    as = ["10", "8", "7"]
Run Code Online (Sandbox Code Playgroud)

y 是常量(作为参数传入)并且我已经删除了许多其他函数,因为它们正在返回我期待的内容.

我有一个看起来像的数组

1,1,1
1,1,1
1,1,1
Run Code Online (Sandbox Code Playgroud)

我希望得到(例如)

1,1,10
1,1,8
1,1,7
Run Code Online (Sandbox Code Playgroud)

但相反,我得到了

1,1,7
1,1,7
1,1,7
Run Code Online (Sandbox Code Playgroud)

有人能提供任何建议吗?

haskell functional-programming list

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

Windows 10 NotifyIcon Icon看起来总是非常像素化

我在Windows 10中制作NotifyIcon时遇到问题,其图标资源看起来只是模糊不清.

图标

这种情况发生在SystemIcons课堂上的两个图标或我自己的使用中Properties.Resources.我尝试使用Icon (Icon original, int width, int height)构造函数创建一个新的图标实例,以及各种其他疯狂的东西,包括这个块:

Icon ico = Icon.FromHandle((new Icon(Resources.InfoIcon, 256, 256).ToBitmap()).GetHicon());
Run Code Online (Sandbox Code Playgroud)

无济于事.任何意见,将不胜感激!

.net c# graphics icons winforms

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

有人可以帮我解释一下这个递归函数吗?

#include <stdio.h>
#include <stdlib.h>

void reprint(char *a[]) {
    if(*a) {
            printf("%d ",a);
            reprint(a+1);
            printf("%s ",*a);
    }
}

int main() {
    char *coll[] = {"C", "Objective", "like", "don't", "I", NULL};
    reprint(coll);
    printf("\n");
    return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

正如经验丰富的人所知,这会反过来打印阵列.我不太明白怎么做!

我需要帮助了解是什么reprint(char *a[]).我理解指针算术的程度,但是从插入printfs到此处,我已经确定函数递增到数组结束,然后返回到开始,只在向下打印.但是,我不明白它是如何做到的; 通过查看实际代码我已经设法理解的是,如果*a不是NULL,那么在下一个索引再次调用reprint.

c printing arrays recursion pointers

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

在C#中解决继承问题

我在理解如何实现继承方面遇到了一些麻烦.

我的模型纯粹是出于演示的目的,但我们走了:

我有一个家长班Bus.它有两个孩子DieselBusElectricBus.这些是抽象类.

我有另外两个班CoachCityBus.我如何设置这些后,继承无论从DieselBusOR ElectricBus,而不必单独定义CoachCityBus类,比如CoachDieselBus,CoachElectricBus,CityBusDieselBusCityBusElectricBus?这甚至可行/可能吗?

到目前为止,我没有一些仅仅是一些骷髅的例子,在这一点上寻求建议.

我要找的是这个: 正确

与此相反: 不正确

谢谢!

编辑(2013-07-03):

首先,一些代码:

Bus.cs

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

namespace InheritanceTest {
    abstract class Bus {
        public Bus () {

        }

        public abstract Engine EngineType {
            get;
            set;
        }

        private int id;
        public int ID {
            get {
                return id;
            }
            set {
                id …
Run Code Online (Sandbox Code Playgroud)

c# inheritance

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

将String - > [String] - > [String]类型的函数应用于两个[String]

我努力想出一个好头衔.

这是要点:

我有一个函数(remIgnored)打算从字符串列表中删除字符串.

module Main(main) where

import System.Environment
import Data.List
import Data.Char

getLines :: FilePath -> IO [String]
getLines path = do 
    ls <- readFile path
    return (lines ls)

getWords :: [String] -> [String]
getWords ws = words (unlines ws)

remIgnored :: String -> [String] -> [String]
remIgnored _ []                 = []
remIgnored x (y:ys) | x == y    = remIgnored x ys
                    | otherwise = y : remIgnored x ys

main :: IO ()
main = do …
Run Code Online (Sandbox Code Playgroud)

string haskell types function list

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