我想重复应用一个函数,simplify'直到结果"稳定"(即simplify'(x) == x):
simplify :: Expr -> Expr
simplify expr =
let iterations = iterate simplify' expr
neighbours = zip iterations (tail iterations)
simplified = takeWhile (\(a, b) -> a /= b) neighbours
in snd $ last ((expr, expr) : simplified)
simplify' :: Expr -> Expr
Run Code Online (Sandbox Code Playgroud)
这似乎是我常见的问题.有更优雅的解决方案吗?
更新:我找到了一个更简单的解决方案,但我仍然在寻找更优雅的解决方案:)
simplify expr =
let next = simplify' expr
in if next == expr
then expr
else simplify next
Run Code Online (Sandbox Code Playgroud) 我有三个全屏周视图,一次加载(上一个,下一个,当前).每周视图有7列(一周中的每一天),具有可绘制的背景.
我的可绘制资源背景是
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Grey border on left and right --><item><shape><solid android:color="#999"/></shape></item>
<!-- White background (.5pt to not cover border) --><item android:left=".5pt" android:right=".5pt"><shape>solid android:color="#FFF"/></shape></item>
<!-- Image that repeats to make a grid --><item android:left=".5pt" android:right=".5pt"><bitmap android:src="@drawable/grid" android:tileMode="repeat" android:gravity="center" /></item>
<!-- Times that align left. (12AM, 1AM, etc) --><item android:left="1pt" android:right=".5pt"><bitmap android:src="@drawable/grid_times" android:gravity="top|left|clip_horizontal" /></item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
出于某种原因,如果我有三组七个在彼此前面,只有前面(可见一个)获得重复图像(实际上是一个gif).如果我将前面移开,你可以看到其他人没有得到重复的图像
布局是RelativeLayout,其中包含三个子类RelativeLayout.这三个子类彼此相同,并且覆盖dispatchTouchEvent允许它们被拖动.它们从彼此顶部开始,因此只有前面的一个可见.它们几乎完全相同,只是其中一个在顶部(首先).
这是android的顶视图
' first '
' second '
' third '
| |#<-- The android screen boundaries. Only …Run Code Online (Sandbox Code Playgroud) 如何每10秒重复一次jQuery ajax调用?
$(document).ready(function() {
$.ajax({
type: "GET",
url: "newstitle.php",
data: "user=success",
success: function(msg) {
$(msg).appendTo("#edix");
}
});
Run Code Online (Sandbox Code Playgroud)
我试图用函数包装$ .ajax并用setInterval调用该函数
$(document).ready(function() {
function ajaxd() {
$.ajax({
type: "GET",
url: "newstitle.php",
data: "user=success",
success: function(msg) {
$(msg).appendTo("#edix");
}
});
}
setInterval("ajaxd()",10000);
});
Run Code Online (Sandbox Code Playgroud)
但它说"ajaxd没有定义"
<div id="header">header</div>
<div id="content">
content spanning several pages...
</div>
<div id="footer">Footer - Fixed at the bottom of each page</div>
Run Code Online (Sandbox Code Playgroud)
我想打印#header和#footer对每个打印模式页.我搜索了很多,但似乎没有任何工作,甚至position:fixed没有按预期工作.
Android中是否有任何方法可以检测用户何时向左侧滑动通知并将其删除?我正在使用闹钟管理器来设置重复警报,当用户取消通知时,我需要停止重复警报.这是我的代码:
设置重复提醒:
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), repeatFrequency, displayIntent);
Run Code Online (Sandbox Code Playgroud)
我的通知代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get the notification ID.
int notifID = getIntent().getExtras().getInt("Reminder_Primary_Key");
//Get the name of the reminder.
String reminderName = getIntent().getExtras().getString("Reminder_Name");
//PendingIntent stores the Activity that should be launched when the user taps the notification.
Intent i = new Intent(this, ViewLocalRemindersDetail.class);
i.putExtra("NotifID", notifID);
i.putExtra("notification_tap", true);
//Add FLAG_ACTIVITY_NEW_TASK to stop the intent from being launched when the notification is triggered.
PendingIntent displayIntent = PendingIntent.getActivity(this, notifID, …Run Code Online (Sandbox Code Playgroud) 在Unix中,^允许您重复一个命令,其中一些文本替换为新文本.例如:
csh% grep "stuff" file1 >> Results
grep "stuff" file1
csh% ^file1^file2^
grep "stuff" file2
csh%
Run Code Online (Sandbox Code Playgroud)
是否有Vim等价物?很多时候,我发现自己在命令行上一遍又一遍地编辑小事.
在Vim中,我通常希望有时重复一些命令.说,我想评论5行,我会用
I//<Esc>j
.j.j.j.j
Run Code Online (Sandbox Code Playgroud)
有没有办法多次重复最后一个".j"部分?
是否有任何属性告诉(标准)NumberPicker在其最后一个值之后停止?例如,如果我的MinValue为0且我的MaxValue为5,则NumberPicker仅在5之后重复,以便用户可以无限滚动.
我正在学习在Emacs中导航/编辑的基础知识,我很好奇如何完成以下任务:
假设我想重复五次以产生'bla bla bla bla bla'.我试过了...
C-u 5 bla
Run Code Online (Sandbox Code Playgroud)
...但是在输入'b'后执行命令,我只得到'bbbbb'.
我敢肯定有一些基本的命令可以帮助我在这里......有人会善意地开导我:)?