A recursive datastructure is a datastructure (e.g. a struct or class) that contains one or several references to instances of the same datastructure as a member.
Questions tagged [recursive-datastructures]
402 questions
6
votes
1 answer
How to define a recursive data type that refers to its definition
I want to write a data type to evaluate the expressions like this:
a is evaluated to a
a + b * c / d -e is evaluated to a + (b * (c / (d - e)))
So the first argument is always a number and the second one is either a number or an expression
I…
![](../../users/profiles/1374828.webp)
Ali
- 75
- 5
6
votes
2 answers
Recursive data type like a tree as Avro schema
Reading https://avro.apache.org/docs/current/spec.html it says a schema must be one of:
A JSON string, naming a defined type.
A JSON object, of the form:
{"type": "typeName" ...attributes...} where typeName is either a
primitive or derived type…
![](../../users/profiles/613973.webp)
adelbertc
- 6,965
- 10
- 42
- 65
5
votes
1 answer
How to store recursive datatype with Data.Binary
Data.Binary is great. There is just one question I have. Let's imagine I've got a datatype like this:
import Data.Binary
data Ref = Ref {
refName :: String,
refRefs :: [(String, Ref)]
}
instance Binary Ref where
put a = put (refName a)…
![](../../users/profiles/471436.webp)
Lanbo
- 13,437
- 14
- 67
- 141
5
votes
4 answers
How to create recursive tree-like data structure in java using Map?
I have a mind-block when trying to create data-structure that follows the pattern:
Map is a main building block and T is either Map or as terminal operator List. Is it possible to build anything similar in Java, this…
![](../../users/profiles/4473386.webp)
Dmytro Chasovskyi
- 2,169
- 3
- 18
- 44
5
votes
2 answers
Recursive variable definitions in Python and F# (probably OCaml, too)
Given these F# type declarations...
type Message =
| MessageA
| MessageB
| MessageC
| MessageD
type State = {
Name:string
NextStateMap: Map
}
...is there an equally expressive definition of this specific…
![](../../users/profiles/382050.webp)
ttsiodras
- 7,771
- 4
- 43
- 62
5
votes
1 answer
Haskell AST Annotation with Fix
I am working on creating an AST in Haskell. I want to add different annotations, such as types and location information, so I ended up using fixplate. However, I can't find any examples online and am having some difficulty.
I've set up my AST as…
![](../../users/profiles/374797.webp)
John Howard
- 50,339
- 21
- 44
- 63
5
votes
2 answers
Recursion schemes using `Fix` on a data-type that's already a Functor?
Still working on my text editor Rasa.
At the moment I'm building out the system for tracking viewports/splits (similar to vim splits). It seemed natural to me to represent this structure as a tree:
data Dir = Hor
| Vert
deriving…
![](../../users/profiles/3907685.webp)
Chris Penner
- 1,835
- 8
- 14
5
votes
2 answers
Limited function calls in nodejs on same operation?
I am currently working on some scientific calculations for which my base calculation loops are executed over and over again with recursive calls as long as at least one parameter is false.
Currently my nodejs server stops at around 905 - 915th…
![](../../users/profiles/4657699.webp)
noa-dev
- 3,179
- 9
- 29
- 62
5
votes
2 answers
bifunctor in haskell after the least fixed type
I am not sure how to derive the functor instance after making a fixed point :
data FreeF f a next = PureF a | FreeF (f next) deriving (Functor)
data Mu f = In { out :: f ( Mu f ) }
newtype Free f a = Free( Mu (FreeF f a) )
instance Functor f…
![](../../users/profiles/242189.webp)
nicolas
- 8,208
- 3
- 32
- 69
5
votes
0 answers
Multi-dimensional Dictionary class in VBA
This post is half to share a solution and half to ask if there's a better way to do it.
Problem: how to build a multi-dimensional dictionary in VBA.
It seems there are people out there looking for one, but there isn't an obvious neat solution around…
![](../../users/profiles/1542692.webp)
Bit Rocker
- 737
- 1
- 7
- 13
5
votes
3 answers
Java Generics Type Safety warning with recursive Hashmap
I'm using a recursive tree of hashmaps, specifically Hashmap map where Object is a reference to another Hashmap and so on. This will be passed around a recursive algorithm:
foo(String filename, Hashmap map)
{
//some stuff here
…
![](../../users/profiles/293572.webp)
GC.
- 53
- 1
- 3
5
votes
1 answer
Why must coq mutually inductive types have the same parameters?
Following Arthur's suggestion, I changed my Fixpoint relation to a mutual Inductive relation which "builds up" the different comparisons between games rather than "drilling down".
But now I am receiving an entirely new error message:
Error:…
![](../../users/profiles/403875.webp)
dspyz
- 4,910
- 2
- 19
- 54
5
votes
2 answers
Operator[] Overloading in MultiDimensional Arrays c++
When I call: a7[0][1][100];
I am able to obtain the first index 0 in the operator[] but as index I won't able to obtain other index values 1 and 100 as recursively. How could I able to use operator[] in order to obtain recursive following index…
![](../../users/profiles/2402577.webp)
alper
- 1,558
- 2
- 24
- 54
4
votes
2 answers
How can I recursively insert the Fibonacci sequence into a binary tree
Hope someone can help, I'm not a programmer, but have been interested in exploring Fibonacci sequence and it's recursive tree...
I've created a Binary Tree class, along with an associated TreeNode class, and want to generate a binary tree of the…
![](../../users/profiles/1194326.webp)
Alex2134
- 527
- 5
- 22
4
votes
2 answers
Recursive data structures in haskell: prolog-like terms
I have a question about recursive data structures in Haskell (language that I'm currently trying to learn).
I would like to encode in Haskell Prolog-like terms, but every solution I came up with has different drawbacks that I would really like to…
![](../../users/profiles/898400.webp)
Riccardo T.
- 8,569
- 5
- 32
- 74