Skip to content

Commit

Permalink
Make concat faster
Browse files Browse the repository at this point in the history
  • Loading branch information
aggelgian committed Jan 15, 2015
1 parent 9cf7f27 commit 049412a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ new size = listArray (0, size - 1) $ cycle [[]]

-- to_list(T) converts a table T into a list of its entries.
to_list :: VTable -> [Vertex]
to_list = concat . elems
to_list arr = concat' (elems arr) []

concat' :: [[Vertex]] -> [Vertex] -> [Vertex]
concat' [] acc = acc
concat' ((h:t):t') acc = concat' (t:t') (h:acc)
concat' (([]):t) acc = concat' t acc

-- is_member(X, I, T) is true iff X is stored in table T at slot I.
is_member :: Vertex -> Int -> VTable -> Bool
Expand Down

0 comments on commit 049412a

Please sign in to comment.