infinite

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

本秂侑毒 提交于 2019-12-04 00:07:24
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 implement cycle as follows: cycle xs = xs ++ cycle xs it is an infinite list, not a cyclic list. To make

线程同步与异步套接字编程(二)

不羁岁月 提交于 2019-12-03 23:47:54
接下来我们介绍利用关键代码段实现线程同步的方法。 关键代码段(临界区)工作在用户方式下。它是指一个小代码段,在代码能够执行前,它必须独占对某些资源的访问权。 关键代码段机制,创建---进入---离开---删除. 1 InitializeCriticalSection( 2 LPCRITICAL_SECTION lpCriticalSection 3 ); 创建初始化函数参数是一个out类型,即作为返回值使用。因此在之前我们需要构造一个CRITICAL_SECTION结构型对象,然后将该对象地址传递给InitializeCriticalSection函数,由系统自动维护该对象。 进入关键代码段函数:EnterCriticalSection 离开关键代码段函数:LeaveCriticalSetion 删除函数: DeleteCriticalSection 这三个函数都只有一个参数,该参数为CRITICAL_SECTION结构型对象指针。 接下来将之前的例程用关键代码段来实现多线同步处理: 1 #include<windows.h> 2 #include<iostream.h> 3 4 DWORD WINAPI Fun1Proc(LPVOID lpParameter); 5 DWORD WINAPI Fun2Proc(LPVOID lpParameter); 6 7 int tick

Would the ability to detect cyclic lists in Haskell break any properties of the language?

怎甘沉沦 提交于 2019-12-03 23:25:48
问题 In Haskell, some lists are cyclic: ones = 1 : ones Others are not: nums = [1..] And then there are things like this: more_ones = f 1 where f x = x : f x This denotes the same value as ones , and certainly that value is a repeating sequence. But whether it's represented in memory as a cyclic data structure is doubtful. (An implementation could do so, but this answer explains that "it's unlikely that this will happen in practice".) Suppose we take a Haskell implementation and hack into it a

VB.NET - It keep replacing itself

Deadly 提交于 2019-12-03 21:32:29
I have in a text file lines of this format: word1|word2|word3 anotherword1|anotherword2 I'm trying to split each word one by one per every line of that file and once program detect if the richtextbox has one of these words will replace that word with the unsplitted line. Example: From word1 to word1|word2|word3 Here is what I have so far: Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click For Each line As String In File.ReadLines("C:\text.txt") Dim input As String = line Dim result As String() = line.Split(New String() {"|"}, StringSplitOptions.None) For Each s

Best infinite loop [duplicate]

吃可爱长大的小学妹 提交于 2019-12-03 15:58:35
Possible Duplicate: while (1) Vs. for (;;) Is there a speed difference? Hi, Which is better,faster and more optimized way to implement infinite loop - for(;;) or while(1)? and why? In any normal compiler, there should be absolutely no difference. For example, here's what LLVM-clang generates (with the -O3 flag) for while (1) {} : .file "test.c" .text .globl main .align 16, 0x90 .type main,@function main: pushl %ebp movl %esp, %ebp .align 16, 0x90 .LBB0_1: jmp .LBB0_1 Note the jmp .LBB0_1 part, which is the actual infinite loop. For the for (;;) kind, it generates absolutely the same code . You

Infinite scroll plugin modify the path with custom query

无人久伴 提交于 2019-12-03 15:37:50
I am using the infinite scroll plugin ( infinite-scroll ) with jQuery isotope and was wondering if it's possible to modify the path with custom query parameters as user scrolls down the page to view more items. Is there a way to access the path and modify one of the query parameter. It's hitting the path ok for the first time returning the first set of items and after that it hitting the next pages , 1,2 3 ok but using the same query parameters I used for the first time only updating the page number. I would like to modify one of the parameter when hitting page 3 or 4 with something like this:

vue-infinite-loading使用demo

孤街浪徒 提交于 2019-12-03 12:15:37
vue-infinite-loading官网: https://peachscript.github.io/vue-infinite-loading/ 安装: npm install vue -infinite -loading -- save list.vue页面 < template > < div class = "list-con" > < div class = "list" v-for = "(item,key) in list" > < span v-text = "key+1" > </ span > < p > < a :href = "item.url" > {{ item.title }} </ a > </ p > </ div > < infinite-loading :on-infinite = "onInfinite" ref = "infiniteLoading" > < span slot = "no-more" > 没有更多消息了 </ span > </ infinite-loading > </ div > </ template > < script > import InfiniteLoading from 'vue-infinite-loading' ; const api = 'http://hn.algolia.com/api/v1

jCarousel Infinite Loop - no width or height set

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've setup jcarousel to dynamically load elements as they disappear and then have them reappear now it's given me an error saying: "No width/height set for items." I've tried the hack described here: http://old.nabble.com/jCarousel:-No-width-height-set-for-items.-td13913308s27240.html and it caused firefox to crash (probably because it's looping constantly) any ideas? 回答1: You need to set an explicit height on the .jcarousel-clip container 回答2: jQuery ( '#mycarousel' ). jcarousel ( { auto : 2 , scroll : 1 , wrap : 'last' ,

how do I compute this infinite sum in matlab?

匿名 (未验证) 提交于 2019-12-03 09:58:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to compute the following infinite sum in Matlab, for a given x and tau: infsum http://i47.tinypic.com/16ih3m1.jpg I tried the following code, given x=0.5 and tau=1: symsum((8/pi/pi)*sin(n*pi*0.5)*sin(n*pi*0.5)*exp(-n*n*pi*pi)/n/n,1,inf) But I get this: (228155022448185*sum((exp(-pi^2*n^2)*((exp(-(pi*n*i)/2)*i)/2 - (exp((pi*n*i)/2)*i)/2)^2)/n^2, n == 1..Inf))/281474976710656 I want an explicit value, assuming the sum converges. What am I doing wrong? It seems like Matlab doesn't compute exp() when returning symsum results. How do I

Infinite loop in java.util.HashMap

匿名 (未验证) 提交于 2019-12-03 09:52:54
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some Vaadin code blocking very often here, and I have no idea what the problem can be: Thread 7892: (state = IN_JAVA) - java.util.HashMap.getEntry(java.lang.Object) @bci=61, line=349 (Compiled frame; information may be imprecise) - java.util.HashMap.containsKey(java.lang.Object) @bci=2, line=335 (Compiled frame) - java.util.HashSet.contains(java.lang.Object) @bci=5, line=184 (Compiled frame) - com.vaadin.ui.Table.unregisterPropertiesAndComponents(java.util.HashSet, java.util.HashSet) @bci=85, line=1693 (Compiled frame) - com.vaadin.ui