Questions tagged [unfold]

An unfold function is the opposite (or dual) of a fold. Unfolds recursively generate a list (or other recursive data structure) of values from a seed value.

An unfold function is the opposite (or dual) of a . Unfolds recursively generate a list (or other recursive data structure) of values from a seed value.

Unfold functions are often used functional languages which support to construct a whose values are only created on demand.

40 questions
3
votes
2 answers

HW: Unfolding a list in a specific way

In Programming in Haskell, Graham Hutton defines an unfold for lists as follows: unfold :: (b -> Bool ) -> (b -> a) -> (b -> b) -> b -> [a] unfold p h t x | p x = [] | otherwise = h x : unfold p h t (t x) Define a function • listUnfold :: (b ->…
rlhh
  • 843
  • 2
  • 14
  • 32
2
votes
1 answer

Preserve sub-folding on any level when folding/unfolding the mother ones in Sublime Text

I need to preserve the sub-foldings on folding/unfolding the mother (super) ones. when unfold a Class through Ctrl+Shift+]. it will unfold its fold Functions as well. is it possible to Unfold only parent class instead of applying to its sub…
2
votes
1 answer

SQL - Impala - How to unfold one categorical column into many?

I have the following table : user category number 1 A 8 1 B 6 2 A 1 2 C 9 3 B 5 I want to "unfold" or "dummify" the category column and fill them with…
Vincent
  • 1,199
  • 3
  • 13
  • 37
2
votes
2 answers

R data.table: subsetting data.table/dataframe based on size of row value

This is a basic question, but I'm stumped: I have the following R data.table: library(data.table) DT <- fread('unique_point biased data_points team groupID …
ShanZhengYang
  • 12,508
  • 35
  • 106
  • 190
2
votes
1 answer

Reactive Extensions unfold / scan approach for nested hierarchy

I'm currently building a wizard system for an application, and we're using ReactiveUI and as a result Rx. Each step in the wizard implements IWizardStep where T is just the data type that the wizard ultimately produces. Each step has the…
Clint
  • 5,733
  • 2
  • 23
  • 44
2
votes
1 answer

Google Image Search : Unfolding image details effect with jquery?

I just noticed the nice "new" unfolding effect on Google Image Search when you click on an image. Id like to implement that into my project. Im sure there are already jquery plugins which will do just that. Yet I dunno how this effect may be called…
andibra
  • 153
  • 4
  • 14
1
vote
2 answers

Where I can find an intuitive explanation of PyTorch's Tensor.unfold() being used to get image patches?

Recently I came across some code that extracted (sliding-window style) a number of square patches from an RGB image (or set of them) of shape N x B x H x W. They did this as follows: patch_width = 3 patches = image.permute(0,2,3,1).unfold(dim = 1,…
kairocks2002
  • 426
  • 1
  • 3
  • 15
1
vote
1 answer
1
vote
0 answers

How can I check/see the inside operations and calculations of any Keras (Dense, Conv1D, LSTM) layers?

I have a question about the architecture of the Keras layers. About kind of unfolding the architecture of the layer. For example, I would like to see the main equation used for the Dense layer in Keras, how the n. of neurons, activation function,…
Yevhenii
  • 23
  • 3
1
vote
1 answer

Unfold the loop three times

I got this Java function and I have to write the piece of code which results by unfolding the loop three times. What does it mean? int f(int x, int y) { while (true) { int m = x % y; if(m == 0) return y; x = y; y = m; …
PHPCore
  • 111
  • 8
1
vote
1 answer

Seq.cache with Seq.unfold in F#

I'm trying to cache the result of an infinite sequence of triangle numbers. let triCalc n = (n*(n+1))/2 let triNumC = 0 |> Seq.unfold (fun n -> Some((triCalc n, n+1))) |> Seq.cache However, when I try to cache it doesn't seem to work as I…
1
vote
1 answer

Writing a lazy-as-possible unfoldr-like function to generate arbitrary factorizations

problem formulation Informally speaking, I want to write a function which, taking as input a function that generates binary factorizations and an element (usually neutral), creates an arbitrary length factorization generator. To be more specific,…
peter pun
  • 319
  • 1
  • 7
1
vote
1 answer

How to do unfolding RFC 822

I am trying to write a vCard Parser and am having trouble unfolding lines. As you can see here: http://www.faqs.org/rfcs/rfc822.html look for "unfolding" it says that all the following are valid: Long string continue Long…
Thomaschaaf
  • 17,014
  • 31
  • 90
  • 122
1
vote
1 answer

How can I unfold the recurrence: T(n)=2T((n+2)/3)

I'm trying to solve this recurrence, but I don't know how to unfold it. T(n)=2T((n+2)/3) + 1 Can I ignore that "+2" and solve it as it was 2T(n/3) + 1? This comes from a from a problem that uses a V[a..b] array and makes this return: return V(X) +…
1
vote
2 answers

How lambda function in unfoldr can be used with two arguments in Haskell?

When reading this article I found example of generating Fibonacci sequence with unfoldr function: fibs = unfoldr (\(a,b) -> Just (a,(b,a+b))) (0,1) But when I looked at documentation I found that lambda in unfoldr function takes only one argument…
MainstreamDeveloper00
  • 8,056
  • 13
  • 52
  • 100