abstract-data-type

N-ary trees in C

Which would be a neat implemenation of a N-ary tree in C language? Particulary, I want to implement an n-ary tree, not self-ballancing, with an unbound number of children in each node, in which each node holds an already defined struct, like this for example: struct task { char command[MAX_LENGTH]; int required_time; }; ...

Lists in Haskell : data type or abstract data type?

Hi, From what I understand, the list type in Haskell is implemented internally using a linked list. However, the user of the language does not get to see the details of the implementation, nor does he have the ability to modify the "links" that make up the linked list to allow it to point to a different memory address. This, I suppose, ...

Abstract Data Types in Fortran 77 (Fortran-II)?

I'm attempting to work in Fotran 77, and I've found the need for a tree based data structure. Aside from implementing a tree with an array, is there any way to build a tree with pointer nodes to other nodes, as per a standard implementation in most languages? The documentation for this beast is scarce, and there doesn't appear to be any...

I cannot understand the point of this simple code.

I am doing this assignment, and there are some stuff (from start-up materials) that I cannot comprehend. typedef enum { NORTH, EAST, SOUTH, WEST, NUM_POINTS } Point; typedef Point Course[NUM_POINTS] ; I don't get the idea behind the last line , and how can I use it in the code? ...

Co- and contravariant types in generic priority queue

I'm trying to implement in Scala a generic data type parameterized on a type T, which should be Ordered[T]. Specifically, it's a persistent version of Sleator & Tarjan's skew heap priority queues. After adding lots of complicated type parameter declarations based on the explanation here and in Odersky-Spoon-Venners, I'm down to one compi...

Is it possible to define new ADTs in GHCi

While commenting on new features in ghci I wished that ghci had the ability to declare type declaration and declaring new ADT types, someone informed that it was indeed possible, and after searching I found this page which told me I could do let numUniques' :: (Eq a) => [a] -> Int; numUniques' = length . nub Apparently that same sort...

Best way to implement ad-hoc polymorphism in Haskell?

I have a polymorphic function like: convert :: (Show a) => a -> String convert = " [label=" ++ (show a) ++ "]" But sometimes I want to pass it a Data.Map and do some more fancy key value conversion. I know I can't pattern match here because Data.Map is an abstract data type (according to this similar SO question), but I have been uns...

Reutilizing same c ADT for other types

So i'm having trouble figuring how to overcome this. Take for example, i have a red black tree implementation that works with items: typedef unsigned long int Key; struct rbt_node{ Item item; int color; Key key; struct rbt_node* parent; struct rbt_node* left; struct rbt_node* right; }; then in an Item.h i defi...