I am trying to write a RegEx in .Net to capture the whole function from a list of function that look something like this.
public string Test1()
{
string result = null;
foreach(var item in Entity.EntityProperties)
{
result +=string.Format("inner string with bracket{0}", "test");
}
return result;
}
public string Test5()
{
return str...
Is it possible to implement a QObject for use in QtScript which overloads [] to implement lazy array population?
I want to implement something like this:
var bar = foo["bar"];
and have the value be lazily calculated in C++ code. Is this possible?
...
Is it possible to write a generalised orElse method from Option that takes a variable number of arguments? That is, instead of:
lazy val o1 = { println("foo"); None }
lazy val o2 = { println("bar"); Some("bar") }
lazy val o3 = { println("baz"); Some("baz") }
// ...
o1 orElse o2 orElse o3 // orElse ...
You could use:
orElse(o1, o2, o...
I understand that:
head (map (2**) [1..999999])
Will only actually evaluate 2**1, and none of the rest, but the book I am reading says that:
head (sort somelist)
Will only need to find the smallest item in the list, because that is all that is used. How does this work? As far as I can tell, this would be impossible with the sorting...
Background
The application I am working with has several COM DLLs.
One of the COM DLLs has a global singleton object, which stores pointers to COM interfaces in other DLLs. Because it is a global singleton object, I have employed the lazy initialization idiom because it is possible that the interface I am trying to get a pointer to ex...
I would like to have some sort of lazy initialied object properties in javascript and would thus want to somehow overload the property read and write access i.e.:
var someval = myobj.lazyprop; // invokes myobj.get("lazyprop");
myobj.lazyprop = someval; // invokes myobj.set("lazyprop",someval);
where myobj is some object I provide ...
Given the following code:
let bar =
lazy(
printfn "bar"
())
let foo =
lazy(
printfn "foo"
bar)
In the interactive window (resetting it each time),
When I call let res = foo.Force () I get:
foo
val res : Lazy<unit> = Value is not created.
When I just call foo.Force() , I get:
foo
...
The following two Haskell programs for computing the n'th term of the Fibonacci sequence have greatly different performance characteristics:
fib1 n =
case n of
0 -> 1
1 -> 1
x -> (fib1 (x-1)) + (fib1 (x-2))
fib2 n = fibArr !! n where
fibArr = 1:1:[a + b | (a, b) <- zip fibArr (tail fibArr)]
They are very close to math...
What advantages are there to Lazy Evaluation as opposed to Eager Evaluation?
What performance overhead is there? Is Lazy Evaluation going to be slower or faster? Why(or does it depend on implementation?)?
How does lazy evaluation actually work in most implementations? To me it would seem like it would be much slower and memory intensiv...
I can implement a def with a val where the def takes no arguments:
trait T { def foo: Int }
class C(val foo: Int) extends T
Why can this not be extended to implementing a def taking N args to a val which is a FunctionN? I want it possible to implement something like:
def expensiveOperation(p: Int => Boolean) : List[Int]
With a lazy...
I'm not sure if something like this is even possible in Python, but if it is it'd be really useful (at least to me in this instance).
I have a test framework in which I want to keep the test configuration separate from the test commands. This is useful because it allows you to mix and match configurations/tests without actually having...
Suppose I have a list of Matrices saved in the variable G and apply the following operations:
top[g_] = Minors[g]
Diagonal[top /@ G]
Minorsreturns a matrix where each element is the determinant with the (i,j) row/col deleted, and Diagonal returns a list of the diagonal elements of a matrix.
My question is on the evaluation of these ...
Let's take a function of type (Monad m) => a -> m a. For example:
ghci> let f x = Just (x+1)
I'd like to be able to apply it any number of times. The first thing I tried was
ghci> let times n f = foldr (>=>) return $ replicate n f
The problem is that it won't work for large n:
ghci> 3 `times` f $ 1
Just 4
ghci> 1000000 `times` f $...
Hi, I am trying to understand how and when iterator expressions get evaluated. The following seems to be a lazy expression:
g = (i for i in range(1000) if i % 3 == i % 2)
This one, however fails on construction:
g = (line.strip() for line in open('xxx', 'r') if len(line) > 10)
I do not have the file named 'xxx'. However, since this...
Hi!
Is there a way (using eval or whatever) to evaluate eagerly boolean expressions in python?
Let's see this:
>>> x = 3
>>> 5 < x < y
False
Yikes! That's very nice, because this will be false regardless of y's value. The thing is, y can be even undefined, and I'd like to get that exception. How can I get python to evaluate all expre...
I'm trying a little experiment in haskell, wondering if it is possible to exploit laziness to process IO. I'd like to write a function that takes a String (a list of Chars) and produces a string, lazily. I would like then to be abily to lazily feed it characters from IO, so each character would be processed as soon as it was available, a...
What I want is a way of not having to 'require' the class under test in each spec file.
So hoping there is a means of setting the root of the source code under test and rspec automatically mapping my tests, or any other means of automatically mapping specs to ruby files.
In Rspec for rails this happens magically, but this is not a ra...
Is it possible to have a list be evaluated lazily in Python?
For example
a = 1
list = [a]
print list
#[1]
a = 2
print list
#[1]
If the list was set to evaluate lazily then the final line would be [2]
...
To solve some problem I need to compute a variant of the pascal's triangle which is defined like this:
f(1,1) = 1,
f(n,k) = f(n-1,k-1) + f(n-1,k) + 1 for 1 <= k < n,
f(n,0) = 0,
f(n,n) = 2*f(n-1,n-1) + 1.
For n given I want to efficiently get the n-th line (f(n,1) .. f(n,n)). One further restriction: f(n,k) should be -1 if it would...
The following code generates a FileNotFoundException (using .NET 2.0):
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace LazyFileInfoTest
{
class Program
{
static void Main(string[] args)
{
File.WriteAllText("Test.txt", "Hello World!");
Directo...