Tree from nesting levels: Difference between revisions

m
m (→‎{{header|Haskell}}: return -> pure)
Line 60:
uncurry (:) $
bimap (Node v . go) go (span ((n <) . fst) xs)
 
--------------------- TEST AND DISPLAY -------------------
Line 84 ⟶ 83:
display = drawTree . Node "Nothing" . fmap (fmap show)
 
----------- MAPPING TO A STRICTER DATA STRUCTURE ---------
 
Line 94 ⟶ 92:
go xs@((1, mb) : _) = xs
go xs@((n, mb) : _) =
fmap (,Nothing) [1 .. pred n] <> xs
(,Nothing)
[1 .. pred n]
<> xs
 
-- Representation of implicit nodes.
9,659

edits