infinite

How to loop select() to poll for data ad infinitum

和自甴很熟 提交于 2019-12-23 10:00:02
问题 #include <stdio.h> #include <unistd.h> #include <sys/time.h> #include <sys/types.h> int main () { char name[20]; fd_set input_set; struct timeval timeout; int ready_for_reading = 0; int read_bytes = 0; /* Empty the FD Set */ FD_ZERO(&input_set ); /* Listen to the input descriptor */ FD_SET(0, &input_set); /* Waiting for some seconds */ timeout.tv_sec = 10; // 10 seconds timeout.tv_usec = 0; // 0 milliseconds /* Invitation for the user to write something */ printf("Enter Username: (in 15

Infinite random sequence loops with randomIO but not with getRandom

时光毁灭记忆、已成空白 提交于 2019-12-23 02:38:33
问题 I'm having difficulty trying to figure out a way to reason about why the following two, seemingly equivalent definitions of an infinite random number sequence ( inf and inf' ) are evaluated completely differently: import Control.Monad.Random (Rand, evalRandIO, getRandom) import System.Random (Random, RandomGen, randomIO) inf :: (RandomGen g, Random a) => Rand g [a] inf = sequence (repeat getRandom) inf' :: (Random a) => IO [a] inf' = sequence (repeat randomIO) -- OK main = do i <- evalRandIO

infinite loop in while loop

一笑奈何 提交于 2019-12-22 20:46:10
问题 fp=fopen("Product.dat","rb+"); while (fread(&prod,sizeof (prod),1,fp)==1) { prod.stockquant = prod.stockquant + prod.stockorderquant; prod.stockorderquant = 0; fseek(fp, -sizeof(prod), SEEK_CUR); fwrite (&prod, sizeof(prod), 1, fp); } fclose (fp); Once I get into the while loop, I am getting an infinite loop. The file pointer is fp, the prod is an instance of Struct called PRODUCT, stockquant and stockorderquant ara variables in the struct. I am attempting to change the values of stockquant

iPhone and iPad end of scrolling

ぐ巨炮叔叔 提交于 2019-12-22 07:04:21
问题 I'm making some jQuery cross-browser gallery with infinite scroll i works great but on iPhone (i suppose also on iPad) instead equal values i have some disproportion values don't match ($(window).scrollTop() == ($(document).height() - $(window).height()) i just want to reach the end of scrolling on that , after that i could invoke AJAX script, also have to keep in mind that values changing after two fingers wipe zoom. 回答1: You need to account for the 60px URL text field on iPhone. Try this: (

Infinite list of infinite counters

亡梦爱人 提交于 2019-12-21 09:16:58
问题 For those with suspicious minds, this is not homework, just curious. Given a finite alphabet, is it possible to construct a list of infinitely long words made from the alphabet in reverse lexographic order? i.e. given the alphabet "ab" is it possible to construct the list: ["aaaaaa...", "baaaaa...", "abaaaa...", "bbaaaa...", "aabaaa...", ...] where ... represents the list (and list of lists) extending to infinite length. A naïve attempt is: counters alphabet = [c:ounter | ounter <- counters

What is the difference between a cyclic list and an infinite list in haskell?

拟墨画扇 提交于 2019-12-21 06:59:06
问题 Referencing @dfeuer's answer to this question: Least expensive way to construct cyclic list in Haskell, which says that using cyclic lists 'defeats' the garbage collector as it has to keep everything you've consumed from a cyclic list allocated till you drop the reference to any cons cells in the list. Apparently in Haskell a cyclic list and an infinite list are two separate things. This blog (https://unspecified.wordpress.com/2010/03/30/a-doubly-linked-list-in-haskell/) says that if you

Can Dijkstra's Single Source Shortest Path Algorithm detect an infinite cycle in a graph?

荒凉一梦 提交于 2019-12-20 10:43:53
问题 So I came to this beautiful problem that asks you to write a program that finds whether a negative infinity shortest path exists in a directed graph. (Also can be thought of as finding whether a "negative cycle" exists in the graph). Here's a link for the problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=499 I successfully solved the problem by running Bellman Ford Algorithm twice by starting with any source in the graph. The second time I

Scala, repeat a finite list infinitely

百般思念 提交于 2019-12-20 08:56:49
问题 I want to use Stream class in scala to repeat a given list infinitely. For example the list (1,2,3,4,5) I want to create a stream that gives me (1,2,3,4,5,1,2,3,4,5,1,2,3....) So that I can wrap the take operation. I know this can be implemented in other ways, but I wanna do it this way for some reason, just humor me :) So the idea is that with this infinite cycle created from some list, I can use take operation, and when it reaches the end of the list it cycles. How do I make a stream which

更多箭头按钮不停闪烁animation

Deadly 提交于 2019-12-20 01:48:28
我们常见的一个效果就是 有向右或者向后的箭头在不停地显隐闪烁 指引我们点进去查看更多。 附上简单的几张效果图: 附上代码: 主要应用的是css3 animation动画效果及其中无限循环的属性 /* animation-iteration-count: n|infinite; 定义播放的次数n次|无限循环infinite*/ <head> <meta charset="UTF-8"> <title>箭头显隐切换或不停闪烁动画效果</title> <style> div{ font-size: 30px; color: red; margin: 100px; opacity:1; animation: jiantou 2s infinite; -moz-animation: jiantou 2s infinite; -webkit-animation: jiantou 2s infinite; -o-animation: jiantou 2s infinite; } @keyframes jiantou{ 0%{opacity: 1;} /* 修改要变换的属性opacity 必须在原dom中体现过该属性*/ 25%{opacity: 0;} 50%{opacity: 1;} 75%{opacity: 0;} 100%{opacity: 1;} } @-moz-keyframes

How to update a TextView in an activity constantly in an infinite loop?

巧了我就是萌 提交于 2019-12-19 02:47:53
问题 I have an activity which has a TextView, and I want to update the text constantly.. In Java I could just make an infinite while loop, and just set the text each iteration. But when I try to do that in Android, it shows a black screen, and doesn't even load the activity. I put the infinite in the onCreate method, perhaps that's why it crashes..but if it is, where should I put it? 回答1: use Handler and a separate thread/runnable for updating TextView constantly instead of While loop : Handler