Last active
December 20, 2015 15:39
-
-
Save Orcomp/6155383 to your computer and use it in GitHub Desktop.
I am trying to print a list of objects as a comma separated string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [<StructuredFormatDisplay("{Print}")>] | |
| type StockLevel = | |
| {Product:string; Quantity:int; Date:DateTime} | |
| override m.ToString() = String.Format("{0},{1},{2}", m.Product, m.Quantity, m.Date) | |
| member m.Print = m.ToString() | |
| let rand = new Random() | |
| let stockLevelCreator (x:int) (y:int) = {Product= "A" + y.ToString(); Quantity=rand.Next(0,100); Date= DateTime.Now.AddDays(x |> float)} | |
| let stockLevels = | |
| [for product in [1..2] do | |
| for days in [1..10] do | |
| yield stockLevelCreator days product] | |
| stockLevels |> List.map (fun o -> printfn "%s" (o.ToString())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment