infinite

Is there any way to separate infinite and finite lists?

£可爱£侵袭症+ 提交于 2019-11-29 04:21:32
For example, I am writing some function for lists and I want to use length function foo :: [a] -> Bool foo xs = length xs == 100 How can someone understand could this function be used with infinite lists or not? Or should I always think about infinite lists and use something like this foo :: [a] -> Bool foo xs = length (take 101 xs) == 100 instead of using length directly? What if haskell would have FiniteList type, so length and foo would be length :: FiniteList a -> Int foo :: FiniteList a -> Bool length traverses the entire list, but to determine if a list has a particular length n you only

How do streams stop?

荒凉一梦 提交于 2019-11-29 04:19:34
I was wondering when I created my own infinite stream with Stream.generate how the Streams which are in the standard library stop... For example when you have a list with records: List<Record> records = getListWithRecords(); records.stream().forEach(/* do something */); The stream won't be infinite and running forever, but it will stop when all items in the list are traversed. But how does that work? The same functionality applies for the stream created by Files.lines(path) (source: http://www.mkyong.com/java8/java-8-stream-read-a-file-line-by-line/ ). And a second question, how can a stream

CSS3 流动边框

孤者浪人 提交于 2019-11-29 04:18:02
CSS3 流动边框(仿王者荣耀等待效果)的三种实现方式 原地址 https://www.jianshu.com/p/3c241aeae992 <!DOCTYPE html> <html> <head> <meta charset="utf8"> <style> :root { --border-anim-size: 10em; --border-anim-width: calc(var(--border-anim-size) / 20); --border-anim-width-double: calc(var(--border-anim-width)*2); --border-anim-duration: 5s; --border-anim-border-color: gray; --border-anim-hover-color: LightCoral; } body { display: flex; } .border-anim { width: var(--border-anim-size); height: var(--border-anim-size); position: relative; border: 1px solid var(--border-anim-border-color); } .border-anim::before, .border-anim:

css3实现椭圆轨迹旋转

 ̄綄美尐妖づ 提交于 2019-11-29 02:43:35
css3实现椭圆轨迹旋转 实现效果 X轴Y轴在一个矩形内移动 做斜线运动 1 .ball { 2 position: absolute; 3 animation: 4 animX 2s linear infinite alternate, 5 animY 2s linear infinite alternate 6 } 7 @keyframes animX{ 8 0% {left: 0px;} 9 100% {left: 500px;} 10 } 11 @keyframes animY{ 12 0% {top: 0px;} 13 100% {top: 300px;} 14 } 设置动画延时 设置Y轴延时为动画时长的一半, 运动轨迹变成菱形 1 .ball { 2 animation: 3 animX 2s linear 0s infinite alternate, 4 animY 2s linear -1s infinite alternate 5 } 设置三次贝塞尔曲线 1 .ball { 2 animation: 3 animX 2s cubic-bezier(0.36, 0, 0.64, 1) -1s infinite alternate, 4 animY 2s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate 5 }

jQuery Infinite Scrolling/Lazy Loading

瘦欲@ 提交于 2019-11-28 23:15:39
问题 I'm currently redesigning my website and have been looking into using JavaScript and jQuery. Here is what I have so far: http://www.tedwinder.co.uk/gallery2/. My vision is to have all of the photos on one page, which the user can scroll through, like now. However, I understand the limitations and effects of having 50+ large-ish images on one page and have considered using infinite scrolling and lazy loading, which I understand would only load the images when the user gets to them, or when

How to tell if a list is infinite?

耗尽温柔 提交于 2019-11-28 22:23:08
Is there a way to tell if a list in Haskell is infinite? The reason is that I don't want to apply functions such as length to infinite lists. C. A. McCann Applying length to unknown lists is generally a bad idea, both practically due to infinite lists, and conceptually because often it turns out that you don't actually care about the length anyway. You said in a comment: I'm very new to Haskell, so now, don't infinite structures make my programs very vulnerable? Not really. While some of us wish there were better ways to distinguish between necessarily finite and necessarily infinite data, you

博客背景西游记

血红的双手。 提交于 2019-11-28 20:16:38
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>西游记</title> <style type="text/css"> /* * */ .bajie { position: absolute; top: 72px; right: 388px; /*background: url(img/o_bajie.png) 0 0 no-repeat;*/ background: url(https://images.cnblogs.com/cnblogs_com/1212dsa/1534470/o_o_bajie.png) 0 0 no-repeat; z-index: 999999; width: 200px; height: 180px; animation: bjzou 1s steps(8) infinite; -webkit-animation: bjzou 1s steps(8) infinite } @keyframes

Javascript: “Infinite” parameters for function?

北城以北 提交于 2019-11-28 18:34:16
问题 In Chrome, when I type console.log in the one below: console.log("A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter"); ...it prints it correctly, with no errors or warnings. I appended more parameters, but it still prints it out correctly. console.log("A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter", "A parameter"

Why does this Haskell code work successfully with infinite lists?

吃可爱长大的小学妹 提交于 2019-11-28 17:50:51
I have some Haskell code that does work correctly on an infinite list, but I do not understand why it can do so successfully. (I modified my original code -- that did not handle infinite lists -- to incorporate something from some other code online, and suddenly I see that it works but don't know why). myAny :: (a -> Bool) -> [a] -> Bool myAny p list = foldr step False list where step item acc = p item || acc My understanding of foldr is that it will loop through every item in the list (and perhaps that understanding is incomplete). If so, it should not matter how the "step" function is

How to implement an infinite image loop?

对着背影说爱祢 提交于 2019-11-28 14:38:00
I am currently working on a 2D shooter with moving background. The background is just a simple image. I want to implement that the image is moving endless from top to bottom. I thought about determining the part of the image that is at the bottom outside the visible part of the frame and paint it on the top again. @Override public void paint(Graphics go) { Graphics2D g = (Graphics2D) go; g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.drawImage(this.imgBackground, 0, this.yBackground, this); } yBackground is the coordinate where the upper left corner of the image is drawn. It is altered