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
1
vote
1 answer

Weird couldn't match type error

I have simple one line function: revRange :: (Char,Char) -> [Char] revRange t = unfoldr (\b -> if b == (pred (fst t)) then Nothing else Just (b, pred b)) (snd t) It works well: *Main Data.List> revRange ('a', 'f') "fedcba" Then I want to extract…
David
  • 634
  • 5
  • 18
1
vote
1 answer

C#: Image unfolding to a rectangle

I need an advice in image processing. I have WF application coded in C# which finds me a coordinates by given parameters and based on this coordinates I would like to crop the image to a circle and unfold this circle to a rectangle. So just to…
0
votes
0 answers

Flutter adding "unfold and fold" to FlatButton

I'm trying to get each FlatButton to "Unfold and Fold". So when anywhere, on a row with a arrow_down Icon is clicked, I'd like that this Row Expands and Data inside will be displayed. When that same Row as before is clicked, it should fold again. It…
Tempelritter
  • 198
  • 11
0
votes
1 answer

List coalgebra translating code from Haskell to SML

I'm trying to translate this piece of code in Haskell that describes List anamorphism but can't quite get it to work. The final three lines are supposed to generate a function count which given an int will produce an int list [n, n-1, ...,…
0
votes
1 answer

Trying to Pattern match an integer argument "globally" within a function - Scala

First of all I apologize if the title of this is misleading, its based off what I think my issue might be. I am creating a lazy list of tuples, the end goal is to find all pythagorean triples with values less than or equal to n and rather than…
0
votes
1 answer

Haskell: Efficiency iterative map with added noise

I am wondering how to improve the time performance of the white noise addition to the logistic map? The noise is only allowed to be added after calculating the values (as it is an iterative map.) module Generating import System.Random…
val
  • 1
  • 2
0
votes
1 answer

Fibonacci sequence with Unfold in Ocaml

I'm relatively new to Ocaml and think I'm understanding the Unfold function correctly but I just can't see how to make a fibonacci sequence using it. Wouldn't we need to have a holder variable of the last two values so we could find the current one?…
ohhimark
  • 11
  • 4
0
votes
0 answers

Whats going on with my Atom?

If I use unFold with shortkey on last line, it's ok. But that happens in other lines: When the focus is on the last line, everything comes back to normal.
0
votes
1 answer

TCL error with "unfold" function in survival analysis

I am trying to use the unfold function from package RcmdrPlugin.survival. I used the following command: long.df <- unfold(testdf,time="deathint", event="death", cov=list(31:70,71:110), cov.names=c("adopted","age")) However, R is…
EdSeab
  • 1
0
votes
2 answers

Generating list of iterations on own output in Python

Sorry for what seems like a basic question, but I could not find it anywhere. In Python 2, I would like to apply a 1-variable function to its own output storing the list of all steps, i.e. if f(x) returns x*x then iterating from 2, i need to get [2,…
gt6989b
  • 3,737
  • 7
  • 37
  • 56
1 2
3