Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The record type Part
- type Part = {
- Heading : string;
- Text : string;
- IsColumnLayout : bool;
- }
- // Make some test data
- let r = { Heading="Wide part"; Text="This is a wide part"; IsColumnLayout=false }
- let g = { Heading="Column part"; Text="This is a column"; IsColumnLayout=true }
- // A test list
- let parts = [r; r; g; g; g; r; g]
- let b = true
- let c = not b
- // The actual function, using pattern matching
- let rec mapParts = function
- | p :: r :: tail when p.IsColumnLayout && r.IsColumnLayout -> (p, Some(r)) :: mapParts tail
- | p :: tail -> (p, None) :: mapParts tail
- | _ -> []
- //Test it
- parts |> mapParts |> Seq.iter (printf "%A\r\n___\r\n")
Advertisement
Add Comment
Please, Sign In to add comment