lazy-evaluation Questions

3

Solved

The object returned by delay in Scheme is "a promise", but promises are not considered to be a type (so there is no promise? procedure, and it's not listed as a type in R5RS or R6RS). Is there a s...
Magnusson asked 23/9, 2010 at 10:37

1

Solved

Recently I've been trying to understand what, exactly, is forced by GHC upon the evaluation of seq. Suppose I save the below definitions: f :: Int -> [Int] -> [Int] f = \n -> \ns -> if ...
Sherrell asked 18/9 at 19:41

3

Is it possibile to have an java.util.Optional which is evaluated only if needed? I need to pass an Optional to a method (of an API that I cannot change), and this method may or may not make use th...
Gulch asked 1/6, 2017 at 14:59

5

I am using SLF4J with Logback in a Spring Boot application. I was interested in using lazy logging and after some research, I came up with this solution. This works as expected and does not invoke...
Deuteronomy asked 15/4, 2020 at 10:15

5

Solved

I'm working on a homework assignment where we are asked to implement an evaluation strategy called "call by name" in a certain language that we developed (using Scheme). We were given an example ...
Beardsley asked 3/6, 2010 at 2:34

31

Solved

I am trying to read a large file one line at a time. I found a question on Quora that dealt with the subject but I'm missing some connections to make the whole thing fit together. var Lazy=requir...
Trudi asked 27/5, 2011 at 18:49

6

Solved

I am an absolute newbie in Haskell yet trying to understand how it works. I want to write my own lazy list of integers such as [1,2,3,4,5...]. For list of ones I have written ones = 1 : ones a...
Granddad asked 21/3, 2010 at 13:3

4

I would like to try out lazy expression evaluation, but I do not want to dive into Haskel right now. Please, can you help to find what other languages have this feature?
Hamiltonian asked 19/12, 2013 at 7:26

12

Solved

Just curious: In Kotlin, I would love to get some val that can be initialized by lazy, but with a parameter. That's because I need something that's created very late in order to initialize it. Spe...

1

I have a space leak in my Haskell programm, I could pinpoint it to a minimal example as follows. I would expect the following code (albeit not terminating but I don't care) to run in constant memor...
Jaco asked 14/12, 2023 at 21:9

9

Solved

Let's say I have this dictionary in python, defined at the module level (mysettings.py): settings = { 'expensive1' : expensive_to_compute(1), 'expensive2' : expensive_to_compute(2), ... } I w...
Johnathon asked 21/5, 2013 at 11:53

2

Solved

I thought I understood laziness well until I came up with the following code, which yields a <<loop>> error. weird = ([1],[2]) <> weird main = print (head $ fst weird) Intuitivel...
Gastrotrich asked 1/11, 2023 at 18:26

1

Set up: Similar to this question on a MSDN forum, I have a measure that switches between various other measures (some of them much more complex than others). The measure looks like this (my actual ...
Skirl asked 14/5, 2020 at 19:8

3

Solved

A lot of times, I have a big dataframe df to hold the basic data, and need to create many more columns to hold the derivative data calculated by basic data columns. I can do that in Pandas like: ...
Pipestone asked 26/10, 2013 at 10:20

5

Solved

One minor annoyance with dict.setdefault is that it always evaluates its second argument (when given, of course), even when the first argument is already a key in the dictionary. For example: impor...
Canoodle asked 8/7, 2013 at 17:50

3

I have a situation for Ruby, where an object is possibly necessary to be created, but it is not sure. And as the creation of the object might be costly I am not too eager creating it. I think this ...
Khmer asked 17/3, 2010 at 10:26

3

Solved

[1, 2, 3, -1, -2].filter({ $0 > 0 }).count // => 3 [1, 2, 3, -1, -2].lazy.filter({ $0 > 0 }).count // => 3 What is the advantage of adding lazy to the second statement. As per my und...
Serrate asked 19/8, 2018 at 11:13

4

Solved

I have a question about using ugettext and gettext_lazy() for translations. I learned that in models I should use gettext_lazy(), while in views ugettext. But are there any other places, where I sh...
Adham asked 12/11, 2010 at 1:6

10

Solved

When I try to access to my app, I'm getting the following error below: AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you d...
Earldom asked 24/12, 2014 at 0:59

2

Solved

Both 1 and "hello" are in normal form, thus are not thunks. So why does GHCi show that "hello" is a thunk? ghci> x = 1::Int ghci> :sprint x x = 1 ghci> x = "hello...
Boaster asked 16/5, 2023 at 13:9

1

Solved

The wikibook says that: in this expression let z = (length [1..5], reverse "olleh") in ... z is a thunk. But this stackoverflow post says that the outermost layer of z is the data constr...
Orangewood asked 16/5, 2023 at 11:49

2

Solved

Python's any and all built-in functions are supposed to short-circuit, like the logical operators or and and do. However, suppose we have a function definition like so: def func(s): print(s) retu...
Lurcher asked 27/9, 2020 at 16:28

2

Solved

I was having trouble when using foo.value_or(bar()) in my code, because I wasn't expecting the function bar() to be called when the optional variable foo had a value. I've since found this question...
Jelly asked 17/6, 2022 at 4:1

2

Solved

I love using np.fromiter from numpy because it is a resource-lazy way to build np.array objects. However, it seems like it doesn't support multidimensional arrays, which are quite useful as well. ...
Orchidectomy asked 1/12, 2015 at 10:47

4

How can I make a lazy list representing a sequence of doubling numbers? Example: 1 2 4 8 16 32
Guardhouse asked 27/10, 2009 at 16:17

© 2022 - 2024 — McMap. All rights reserved.