infinite

Infinite for loops possible in Python?

青春壹個敷衍的年華 提交于 2019-12-19 02:34:38
问题 Is it possible to get an infinite loop in for loop? My guess is that there can be an infinite for loop in Python. I'd like to know this for future references. 回答1: The quintessential example of an infinite loop in Python is: while True: pass To apply this to a for loop, use a generator (simplest form): def infinity(): while True: yield This can be used as follows: for _ in infinity(): pass 回答2: To answer your question using a for loop as requested, this would loop forever as 1 will never be

Haskell- Two lists into a list of tuples

跟風遠走 提交于 2019-12-18 04:52:49
问题 I am trying to implement a function (described below) that takes two lists (each or both may be infinite) and return a list of tuples of all the possible pairs of elements between the lists zipInf :: [a] -> [b] -> [(a,b)] (e.g the output should be like this, but doesn't have to be exactly like this) zipInf [0 .. 2] ['A' .. 'C'] ~> [(0,'A'),(1,'A'),(0,'B'),(1,'B'),(0,'C'),(2,'A'),(2,'B'),(1,'C'),(2,'C')] zipInf [] [0 ..] ~> [] zipInf [0 ..] [] ~> [] take 9 (zipInf ['A'] [0 .. ]) ~> [('A',0),(

R - svd() function - infinite or missing values in 'x'

≯℡__Kan透↙ 提交于 2019-12-17 16:39:36
问题 I am constantly getting this error. I am sure the matrix does not have any non-numeric entries. I also tried imputing the matrix, did not work. Anyone know what the error might be? fileUrl <- "https://dl.dropboxusercontent.com/u/76668273/kdd.csv"; download.file(fileUrl,destfile="./kdd.csv",method="curl"); kddtrain <- read.csv("kdd.csv"); kddnumeric <- kddtrain[,sapply(kddtrain,is.numeric)]; kddmatrix <- as.matrix(kddnumeric); svd1 <- svd(scale(kddmatrix)); 回答1: You have columns composed of

Recursive MySQL query?

你。 提交于 2019-12-17 12:37:58
问题 I have a set of data that's organized hierarchically that should be able to grow to an arbitrary size. I need to retrieve the entire tree, but I can't figure out how to do it with just SQL. My current solution is to create a temporary table and use a recursive function to successively query branches of the tree and then store the result in the temporary table which I subsequently query again to produce my desired result. My question is, what I'm doing is essentially what a join does correct?

Python's xrange alternative for R OR how to loop over large dataset lazilly?

…衆ロ難τιáo~ 提交于 2019-12-17 06:49:14
问题 Following example is based on discussion about using expand.grid with large data. As you can see it ends up with error. I guess this is due to possible combinations which is according to mentioned page 68.7 billions: > v1 <- c(1:8) > v2 <- c(1:8) > v3 <- c(1:8) > v4 <- c(1:8) > v5 <- c(1:8) > v6 <- c(1:8) > v7 <- c(1:8) > v8 <- c(1:8) > v9 <- c(1:8) > v10 <- c(1:8) > v11 <- c(1:8) > v12 <- c(1:8) > expand.grid(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) Error in rep.int(rep.int(seq_len

CSS pusle雷达动画实现

半世苍凉 提交于 2019-12-16 23:58:47
思路同时改变透明度和圆圈的大小,无限循环 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> @keyframes warn { 0% { transform: scale(0); opacity: 0.0; } 25% { transform: scale(0); opacity: 0.1; } 50% { transform: scale(0.1); opacity: 0.3; } 75% { transform: scale(0.5); opacity: 0.5; } 100% { transform: scale(1); opacity: 0.0; } } .container { position: relative; border: 1px solid #000; background: #f55e55; } .part { position: relative; margin: 200px auto; width: 90px; height: 90px; background: #f55e55; } /* 产生动画(向外扩散变大)的圆圈 */ .pulse-max

weui实现滚动加载的效果

霸气de小男生 提交于 2019-12-16 11:51:45
weui是微信公司提供的一个UI框架,在H5开发中一些组件可以直接使用。weui文档地址: http://www.jqweui.cn/components 使用weui,需要引入weui.css和jquery-weui.min.css,还有jquery.min.js和jquery-weui.min.js。库文件下载地址: https://github.com/LuoYiHao/front-end-lib/tree/master/weui 为了实现滚动加载的效果,首先实现加载列表的函数: function getActivityList(pageNum) { //请求消息 if(true){ $.ajaxDirect("/list?pageSize=10&pageNum="+pageNum,'POST',{}, function(data){ list = data.data.list lastPage = data.data.lastPage }, function(){ aiui.toast("请求失败", "text") } ) } } 进入页面先调用接口加载10条数据,并获取当前数据库页数为lastPage。 var pageNum = 1 getActivityList(pageNum) var list var lastPage 然后实现滚动加载: // 上滑加载更多 $

HasNextInt() Infinite loop [closed]

对着背影说爱祢 提交于 2019-12-13 11:28:38
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . //input: multiple integers with spaces inbetween Scanner sc = new Scanner(System.in); while(sc.hasNextInt()) { //add number to list } sc.hasNextInt() is waiting for an integer . It only breaks out if you input a non-integer character. I saw a solution here before not too long ago but i cant find it

How To Register user Form with all dynamic fields name in php

强颜欢笑 提交于 2019-12-13 09:28:05
问题 <form method="post"> User Name : <input type="text" name="values[]"><br/> User Mobile: <input type="text" name="values[]"><br/> User Email: <input type="text" name="values[]"><br/> <input type="submit" name="submit" values="submit"> </form> My Code/Logic <?php $con=mysql_connect('localhost','root',''); mysql_query('testing_user',$con); if(isset($_POST['submit'])) { $x=$_POST['values']; $data_values=array(); for($i=0;$i<count($x);$i++) { echo $x[$i]."<br/>"; array_push($data_values,$x[$i]); }

why program can exactly display infinite repeating floating point number in java or other language

懵懂的女人 提交于 2019-12-13 07:51:16
问题 like a decimal number 0.1, represented as binary 0.00011001100110011...., this is a infinite repeating number. when I write code like this: float f = 0.1f; the program will rounding it as binary 0 01111011 1001 1001 1001 1001 1001 101, this is not original number 0.1. but when print this variable like this: System.out.print(f); I can get original number 0.1 rather than 0.100000001 or some other number. I think the program can't exactly represent "0.1", but it can display "0.1" exactly. How to