ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 23 Feb 2012 04:53:11 -0600Infinite graphs in sagehttp://ask.sagemath.org/question/8728/infinite-graphs-in-sage/I wonder if there is some sort of lazy evaluation in sage. Assume I want to answer a finite question about some infinite structure that can be represented using finite data. As a contrived example: Consider the graph that has as its vertices the natural numbers and an edge (i,j) whenever i divides j. Is there an elegant (lazy evaluation) way to represent this? For instance I could think of a function that investigates the sizes of connected components below the first 500 primes or such.Tue, 21 Feb 2012 02:46:11 -0600http://ask.sagemath.org/question/8728/infinite-graphs-in-sage/Comment by kcrisman for <p>I wonder if there is some sort of lazy evaluation in sage. Assume I want to answer a finite question about some infinite structure that can be represented using finite data. As a contrived example: Consider the graph that has as its vertices the natural numbers and an edge (i,j) whenever i divides j. Is there an elegant (lazy evaluation) way to represent this? For instance I could think of a function that investigates the sizes of connected components below the first 500 primes or such.</p>
http://ask.sagemath.org/question/8728/infinite-graphs-in-sage/?comment=20269#post-id-20269I don't see why not. That's what things like yield statements and so forth are about. I supposed you'd need to use a Python class to do this - make a class instantiating this graph. But you *would* have to use some Python fu to do this, I suspect, if I understand what you mean by "lazy evaluation". I may not, and my apologies if I've totally misinterpreted your question.Tue, 21 Feb 2012 03:34:07 -0600http://ask.sagemath.org/question/8728/infinite-graphs-in-sage/?comment=20269#post-id-20269Comment by Thomas for <p>I wonder if there is some sort of lazy evaluation in sage. Assume I want to answer a finite question about some infinite structure that can be represented using finite data. As a contrived example: Consider the graph that has as its vertices the natural numbers and an edge (i,j) whenever i divides j. Is there an elegant (lazy evaluation) way to represent this? For instance I could think of a function that investigates the sizes of connected components below the first 500 primes or such.</p>
http://ask.sagemath.org/question/8728/infinite-graphs-in-sage/?comment=20253#post-id-20253Alright, thanks. What I was thinking of is too much to ask for: Let the work of implementing all the logic of local exploration of the data be done by the compiler. There are theoretical reasons for this being impossible in python, for instance you need strict static typing (like in Haskell).Thu, 23 Feb 2012 04:53:11 -0600http://ask.sagemath.org/question/8728/infinite-graphs-in-sage/?comment=20253#post-id-20253