Doubly-linked list/Definition: Difference between revisions

(re-order)
Line 716:
For an efficient implementation, see the <code>Data.FDList</code> module provided by [http://hackage.haskell.org/package/liboleg liboleg]. But before using doubly linked lists at all, see [http://stackoverflow.com/questions/1844195/doubly-linked-list-in-a-purely-functional-programming-language this discussion on Stack Overflow].
 
<lang haskell>import qualified Data.RatioMap as (Rational)M
import qualified Data.Map as M
 
type NodeID = Maybe Rational
Line 748 ⟶ 747:
 
mcons :: a -> Node a -> Node a -> DLList a -> DLList a
mcons a n1 n2 list = M.insert n1id left $.
M.insert midid mid $. M.insert n2id right list
where Node n1val farleftid (Just n2id) = n1
Node n2val (Just n1id) farrightid = n2
Anonymous user