Sha256: f6b9fa7141d46d4774ff37851f4678e3eeaacaf7d35622454486c0e1729d5a57
Contents?: true
Size: 699 Bytes
Versions: 128
Compression:
Stored size: 699 Bytes
Contents
module LinkedList ( LinkedList , fromList, toList, reverseLinkedList , datum, next, isNil, nil, new) where data LinkedList a = Nil | Cons { datum :: a , next :: LinkedList a } new :: a -> LinkedList a -> LinkedList a new = Cons nil :: LinkedList a nil = Nil fromList :: [a] -> LinkedList a fromList = foldr Cons Nil toList :: LinkedList a -> [a] toList Nil = [] toList (Cons x xs) = x : toList xs reverseLinkedList :: LinkedList a -> LinkedList a reverseLinkedList = go Nil where go acc Nil = acc go acc (Cons x xs) = (go $! Cons x acc) xs isNil :: LinkedList a -> Bool isNil Nil = True isNil _ = False
Version data entries
128 entries across 128 versions & 1 rubygems