corecursion Questions

5

Solved

I'm trying to create an Observable where each item is produced via an asynchronous task. The next item should be produced via an async call on the result of the previous item (co-recursion). In "Ge...
Serranid asked 17/7, 2015 at 22:12

1

Solved

This is a corecursive algorithm, because with each iteration it calls itself on data that is greater then what it had before: iterate f x = x : iterate f (f x) It is similar to tail recursion ac...
Superheat asked 10/5, 2020 at 19:42

1

Solved

I want to write Foldable.toList for a non-empty rose tree using an anamorphism, but it seems impossible to extract the last element: import Data.Functor.Foldable data RoseTree a = RoseNode a [Ros...
Dambrosio asked 15/2, 2017 at 4:32

1

Solved

I'm playing around with the language to start learning and I am puzzled beyond my wits about how a recursive definition works. For example, let's take the sequence of the Triangular numbers (TN n ...
Schizoid asked 27/7, 2015 at 14:48

1

Solved

I've defined the infinite list of infinite lists pathCounts and the infinite list of finite lists pathCounts': import Data.Function (fix) nextRow xs = fix $ \ys -> zipWith (+) xs (0:ys) pathC...
Marybelle asked 12/2, 2014 at 15:34

3

Solved

I'm working on a C++ project that requires frequent interaction with a tree structure, which means lots of recursive functions, and I'm looking for ways to improve the code. I came across corecursi...
Potation asked 12/2, 2015 at 17:37

2

Solved

I implemented a broken filter function using an anamorphism from recursion-schemes Hackage library: import Data.Functor.Foldable xfilter :: (a -> Bool) -> [a] -> [a] xfilter f = ana $ pr...
Kronos asked 24/8, 2013 at 18:45
1

© 2022 - 2024 — McMap. All rights reserved.