我试图实现这个逻辑,我只是想知道是否有更好的方法?
if(condition1) {
do1();
}
else if(condition2) {//especially here that I have to check condition3 here and also in the last else if
do2();
if(condition3) {
do3();
}
}
else if(condition3) {
do3();
}
Run Code Online (Sandbox Code Playgroud) 我想创建一个名为Structured的结构数据类型,可用于表示String,Int和List.例如,结构类似于:[ Int,String,Int,[ Int ]].
问题1:如何创建此数据类型?
data Structured = ...
Run Code Online (Sandbox Code Playgroud)
问题2:一个名为Confirm的函数确认输入满足限制,并且签名类型为confirm :: Restriction - > Structure - > Maybe Bool
这是我的班级:
public class T {
public int num = 100;
private int num2 = -1;
//inner class
public static class Inner {
private int num2 = 250;
public void method() {
System.out.println(num2);//calls inner class num
System.out.println(...);//should print class T num
System.out.println(...);//should print class T num2
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何制作第二个和第三个println来打印T类的num和num2?
我有20个TextView,它们id是顺序的,即:
R.id.textView1, R.id.textView2, R.id.textView3 ...
Run Code Online (Sandbox Code Playgroud)
我有一个for循环:
for (int i = 1; i < 21; i++) {
TextView textView = (TextView) findViewById(R.id.textView ...);//
textView.setText("...");
Run Code Online (Sandbox Code Playgroud)
有没有办法TextView使用这个for循环并设置他们的文本?
这是我的ADT:
data Tree a = Val Integer
|Tree a
|Variable a
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
问题1:使用Tree String类型来表示一些树?
问题2:定义一个函数,用于将树,数据类型Tree String的元素转换为字符串:showTree :: Tree String - > String